private static @Nullable PsiClass findContainingClass(@NotNull PsiReferenceExpression ref, @NotNull PsiMember member) {
    PsiClass memberClass = member.getContainingClass();
    PsiClass containingClass = PsiUtil.getContainingClass(ref);
    while (containingClass != null && !InheritanceUtil.isInheritorOrSelf(containingClass, memberClass, true)) {
      if (!member.hasModifierProperty(PsiModifier.STATIC) && containingClass.hasModifierProperty(PsiModifier.STATIC)) return null;
      containingClass = PsiUtil.getContainingClass(containingClass);
    }
    return containingClass;
  }
private static @Nullable PsiClass findContainingClass(@NotNull PsiReferenceExpression ref, @NotNull PsiMember member)