List<PsiClass> (@NotNull PsiMethod method) { List<PsiClass> superClasses = new ArrayList<>(); while (true) { PsiMethod superMethod = Stream.of(method.findSuperMethods()).min(SUPER_METHOD_COMPARATOR).orElse(null); if (superMethod == null || superClasses.contains(superMethod.getContainingClass())) break; superClasses.addAll(0, findInheritanceChain(method.getContainingClass(), superMethod.getContainingClass())); method = superMethod; } return superClasses; }