PsiElement (@NotNull PsiElement item) { if (item instanceof PsiTypeParameter) { PsiElement parent = item.getParent(); return parent == null ? null : parent.getParent(); } if (item instanceof PsiMember) { PsiClass containingClass = ((PsiMember)item).getContainingClass(); return containingClass == null ? item.getContainingFile() : containingClass; } return null; }