PsiElement (@NotNull PsiElement context) { while (true) { PsiElement parent = context.getParent(); if (parent == null) return null; if (parent instanceof PsiPolyadicExpression) { IElementType tokenType = ((PsiPolyadicExpression)parent).getOperationTokenType(); if (tokenType.equals(JavaTokenType.ANDAND) || tokenType.equals(JavaTokenType.OROR)) return parent; } if (parent instanceof PsiIfStatement && ((PsiIfStatement)parent).getCondition() != context) { return parent; } if (parent instanceof PsiConditionalLoopStatement && ((PsiConditionalLoopStatement)parent).getCondition() != context) { return parent; } if (parent instanceof PsiConditionalExpression && ((PsiConditionalExpression)parent).getCondition() != context) { return parent; } context = parent; } }