PsiExpression (@NotNull PsiExpression expression, boolean equal, PsiExpression part1, PsiExpression part2) { final PsiElement parent = PsiTreeUtil.skipParentsOfType(expression, PsiParenthesizedExpression.class); if (parent instanceof PsiBinaryExpression binaryExpression) { final IElementType tokenType = binaryExpression.getOperationTokenType(); if (equal && JavaTokenType.OROR.equals(tokenType) || !equal && JavaTokenType.ANDAND.equals(tokenType)) { if (PsiTreeUtil.isAncestor(binaryExpression.getROperand(), expression, false)) { final PsiExpression lhs = binaryExpression.getLOperand(); if (isEquality(lhs, equal, part1, part2)) { return binaryExpression; } } } } return expression; }