PsiElement (@NotNull final PsiElement host) { PsiElement target = host; PsiElement parent = target.getParent(); for (; parent != null; target = parent, parent = target.getParent()) { if (parent instanceof GrBinaryExpression) continue; if (parent instanceof GrString) continue; if (parent instanceof GrParenthesizedExpression) continue; if (parent instanceof GrConditionalExpression && ((GrConditionalExpression)parent).getCondition() != target) continue; if (parent instanceof GrAnnotationArrayInitializer) continue; if (parent instanceof GrListOrMap) { parent = parent.getParent(); continue; } break; } return target; }