boolean (@Nullable PsiExpression root, @NotNull Predicate<? super PsiExpression> matcher) { if (root == null) return false; AtomicBoolean result = new AtomicBoolean(false); root.accept(new JavaRecursiveElementWalkingVisitor() { @Override public void visitExpression(@NotNull PsiExpression expression) { super.visitExpression(expression); if (matcher.test(expression)) { result.set(true); stopWalking(); } } @Override public void visitConditionalExpression(@NotNull PsiConditionalExpression expression) { if (isMatchingChildAlwaysExecuted(expression.getCondition(), matcher) || (isMatchingChildAlwaysExecuted(expression.getThenExpression(), matcher) && isMatchingChildAlwaysExecuted(expression.getElseExpression(), matcher))) { result.set(true); stopWalking(); } } @Override public void visitPolyadicExpression(@NotNull PsiPolyadicExpression expression) { IElementType type = expression.getOperationTokenType(); if (type.equals(JavaTokenType.OROR) || type.equals(JavaTokenType.ANDAND)) { PsiExpression firstOperand = ArrayUtil.getFirstElement(expression.getOperands()); if (isMatchingChildAlwaysExecuted(firstOperand, matcher)) { result.set(true); stopWalking(); } } else { super.visitPolyadicExpression(expression); } } @Override public void visitClass(@NotNull PsiClass aClass) {} @Override public void visitLambdaExpression(@NotNull PsiLambdaExpression expression) {} }); return result.get(); }