boolean (Set<PsiClass> forbidden, GrTypeDefinition root) { for (PsiClass aSuper : root.getSupers(false)) { if (forbidden.contains(aSuper)) { return true; } forbidden.add(aSuper); if (aSuper instanceof GrTypeDefinition && reachableInHierarchy(forbidden, (GrTypeDefinition)aSuper)) { return true; } } return false; }