private ConditionalExpression tryUnwrapBoolean(ConditionalExpression.Boolean condition, boolean unwrapLazilyEvaluated) {
    if (myChainExpression instanceof PsiExpression) {
      PsiExpression negation = BoolUtils.findNegation((PsiExpression)myChainExpression);
      if (negation != null) {
        myChainExpression = negation;
        condition = condition.negate();
      }

      PsiElement parent = PsiUtil.skipParenthesizedExprUp(myChainExpression.getParent());
      ConditionalExpression candidate = null;
      if (parent instanceof PsiPolyadicExpression expression) {
        PsiExpression[] operands = expression.getOperands();
        if (operands.length > 1 && PsiTreeUtil.isAncestor(operands[0], myChainExpression, false)) {
          IElementType type = expression.getOperationTokenType();
          if (type.equals(JavaTokenType.ANDAND)) {
            candidate = condition
              .toPlain(PsiTypes.booleanType(), StreamEx.of(operands, 1, operands.length).map(PsiExpression::getText).joining(" && "), "false");
          }
          else if (type.equals(JavaTokenType.OROR)) {
            candidate = condition
              .toPlain(PsiTypes.booleanType(), "true", StreamEx.of(operands, 1, operands.length).map(PsiExpression::getText).joining(" || "));
          }
        }
      }
      else if (parent instanceof PsiConditionalExpression ternary &&
               PsiTreeUtil.isAncestor(ternary.getCondition(), myChainExpression, false)) {
        PsiType type = ternary.getType();
        PsiExpression thenExpression = ternary.getThenExpression();
        PsiExpression elseExpression = ternary.getElseExpression();
        if (type != null && thenExpression != null && elseExpression != null) {
          candidate = condition.toPlain(type, thenExpression.getText(), elseExpression.getText());
        }
      }
      if (candidate != null &&
          (unwrapLazilyEvaluated || ExpressionUtils.isSafelyRecomputableExpression(createExpression(candidate.getFalseBranch())))) {
        myChainExpression = parent;
        return candidate;
      }
    }
    return condition;
  }
private ConditionalExpression tryUnwrapBoolean(ConditionalExpression.Boolean condition, boolean unwrapLazilyEvaluated)