PsiMember (@NotNull PsiElement element) { while (true) { PsiMember member = PsiTreeUtil.getParentOfType(element, PsiMember.class, false, PsiCodeBlock.class, PsiStatement.class, PsiExpression.class); if (!(member instanceof PsiTypeParameter)) { return member; } element = member.getParent(); } }