String (PsiClass psiClass, PsiClass expectedClass, Set<String> candidates) { var processor = new Processor<PsiClass>() { String myResult; @Override public boolean process(PsiClass superClass) { String qualifiedName = superClass.getQualifiedName(); if (qualifiedName != null && candidates.contains(qualifiedName)) { if (InheritanceUtil.isInheritorOrSelf(superClass, expectedClass, true)) { myResult = qualifiedName; } return false; } return true; } }; InheritanceUtil.processSupers(psiClass, true, processor); return processor.myResult; }