int (PsiClass aClass) { PsiElement ancestor = aClass.getParent(); int nestingLevel = 0; while (ancestor != null) { if (ancestor instanceof PsiClass) { nestingLevel++; } ancestor = ancestor.getParent(); } return nestingLevel; }