PsiElement (PsiElement element) { PsiElement parent; while(true) { parent = PsiTreeUtil.getParentOfType(element, PsiMember.class, PsiLambdaExpression.class); if (parent instanceof PsiAnonymousClass && PsiTreeUtil.isAncestor(((PsiAnonymousClass)parent).getArgumentList(), element, true)) { element = parent; } else { break; } } return parent; }