PsiClass (PsiClass aClass, PsiClass targetClass) { if (targetClass != null) { if (targetClass.isInheritor(aClass, false)) { return aClass; } for (PsiClassType type : targetClass.getSuperTypes()) { PsiClass superClass = type.resolve(); if (InheritanceUtil.isInheritorOrSelf(superClass, aClass, true)) { return superClass.isInterface() ? superClass : null; } } } return null; }