PsiClass[] (PsiClass anInterface) { Set<PsiClass> result = new HashSet<>(); _findImplementingClasses(anInterface, new HashSet<>(), result); boolean classesRemoved = true; while(classesRemoved) { classesRemoved = false; loop1: for (Iterator<PsiClass> iterator = result.iterator(); iterator.hasNext();) { final PsiClass psiClass = iterator.next(); for (final PsiClass aClass : result) { if (psiClass.isInheritor(aClass, true)) { iterator.remove(); classesRemoved = true; break loop1; } } } } return result.toArray(PsiClass.EMPTY_ARRAY); }