@Override
  PsiElement migrate(@NotNull Project project, @NotNull PsiElement body, @NotNull TerminalBlock tb) {
    PsiStatement sourceStatement = tb.getStreamSourceStatement();
    CommentTracker ct = new CommentTracker();
    if(tb.getSingleStatement() instanceof PsiReturnStatement returnStatement) {
      PsiLiteralExpression literal = ObjectUtils.tryCast(PsiUtil.skipParenthesizedExprDown(returnStatement.getReturnValue()), 
                                                         PsiLiteralExpression.class);
      if (literal != null && literal.getValue() instanceof Boolean) {
        boolean foundResult = (Boolean)literal.getValue();
        PsiReturnStatement nextReturnStatement = ControlFlowUtils.getNextReturnStatement(sourceStatement);
        if (nextReturnStatement != null) {
          PsiExpression returnValue = nextReturnStatement.getReturnValue();
          if(returnValue == null) return null;
          String methodName = foundResult ? "anyMatch" : "noneMatch";
          String streamText = addTerminalOperation(ct, methodName, sourceStatement, tb);
          if (nextReturnStatement.getParent() == sourceStatement.getParent()) {
            if(!ExpressionUtils.isLiteral(returnValue, !foundResult)) {
              streamText += (foundResult ? "||" : "&&") + ct.text(returnValue, ParenthesesUtils.BINARY_OR_PRECEDENCE);
            }
            removeLoop(ct, sourceStatement);
            return new CommentTracker().replaceAndRestoreComments(returnValue, streamText);
          }
          PsiElement result = ct.replaceAndRestoreComments(sourceStatement, "return " + streamText + ";");
          if(!ControlFlowUtils.isReachable(nextReturnStatement)) {
            new CommentTracker().deleteAndRestoreComments(nextReturnStatement);
          }
          return result;
        }
      }
    }
    PsiStatement[] statements = tb.getStatements();
    if (!(statements.length == 1 ||
          (sourceStatement instanceof PsiLoopStatement && statements.length == 2 &&
           ControlFlowUtils.statementBreaksLoop(statements[1], (PsiLoopStatement)sourceStatement)))) {
      return null;
    }
    String streamText = addTerminalOperation(ct, "anyMatch", sourceStatement, tb);
    PsiStatement statement = statements[0];
    PsiAssignmentExpression assignment = ExpressionUtils.getAssignment(statement);
    if(assignment != null) {
      PsiExpression lValue = assignment.getLExpression();
      PsiExpression rValue = assignment.getRExpression();
      if ((lValue instanceof PsiReferenceExpression) && rValue != null) {
        PsiElement maybeVar = ((PsiReferenceExpression)lValue).resolve();
        if (maybeVar instanceof PsiVariable var) {
          // Simplify single assignments like this:
          // boolean flag = false;
          // for(....) if(...) {flag = true; break;}
          PsiExpression initializer = var.getInitializer();
          InitializerUsageStatus status = ControlFlowUtils.getInitializerUsageStatus(var, sourceStatement);
          if (initializer != null && status != ControlFlowUtils.InitializerUsageStatus.UNKNOWN) {
            String replacement;
            if (ExpressionUtils.isLiteral(initializer, Boolean.FALSE) &&
                ExpressionUtils.isLiteral(rValue, Boolean.TRUE)) {
              replacement = streamText;
            }
            else if (ExpressionUtils.isLiteral(initializer, Boolean.TRUE) &&
                     ExpressionUtils.isLiteral(rValue, Boolean.FALSE)) {
              replacement = "!" + streamText;
            }
            else {
              replacement = streamText + "?" + ct.text(rValue) + ":" + ct.text(initializer);
            }
            return replaceInitializer(sourceStatement, var, initializer, replacement, status, ct);
          }
        }
      }
    }
    String replacement = "if(" + streamText + "){" + ct.text(statement) + "\n}";
    return ct.replaceAndRestoreComments(sourceStatement, replacement);
  }
@Override
  PsiElement migrate(@NotNull Project project, @NotNull PsiElement body, @NotNull TerminalBlock tb)