boolean (PsiClass aClass, Set<PsiClass> visited) { if (!visited.add(aClass)) return false; // this class and all its super- and containing- classes should be public if (!aClass.hasModifierProperty(PsiModifier.PUBLIC)) return false; for (PsiClass superClass : aClass.getSupers()) { if (!accessible(superClass, visited)) return false; } PsiClass containingClass = aClass.getContainingClass(); return containingClass == null || accessible(containingClass, visited); }