PsiElement (PsiElement el) { if (el.getParent() instanceof PsiNewExpression) el = el.getParent(); el = findTopmostParentOfType(el, PsiMethodCallExpression.class); el = findTopmostParentOfType(el, PsiAssignmentExpression.class); el = findTopmostParentOfType(el, PsiDeclarationStatement.class); while (el.getParent() instanceof PsiExpressionStatement) { el = el.getParent(); } return el; }