@Nullable
    private static PrimitiveExtremumTerminal extract(@NotNull PsiExpression condition,
                                                     PsiStatement @NotNull [] statements,
                                                     @NotNull TerminalBlock terminalBlock,
                                                     @Nullable List<? extends PsiVariable> nonFinalVariables,
                                                     boolean isNegated) {
      Comparison comparison = Comparison.extract(condition, terminalBlock.getVariable(), isNegated);
      if (comparison == null || comparison.isExternalComparison()) return null;
      if (statements.length != 1) return null;
      PsiAssignmentExpression assignment = ExpressionUtils.getAssignment(statements[0]);
      if (assignment == null) return null;
      PsiVariable extremum = resolveVariableReference(assignment.getLExpression());
      if (extremum == null) return null;
      PsiExpression assignmentLoopVarExpr = assignment.getRExpression();
      PsiExpression comparisonLoopVarExpr = comparison.getLoopVarExpr();
      if (!ourEquivalence.expressionsAreEquivalent(assignmentLoopVarExpr, comparisonLoopVarExpr)) return null;
      PsiVariable comparisonExtremum = resolveVariableReference(comparison.getExtremumExpr());
      if (comparisonExtremum == null) return null;
      if (!extremum.equals(comparisonExtremum)) return null;
      if (mayChangeBeforeLoop(extremum, terminalBlock)) return null;
      if (nonFinalVariables != null) {
        if (containsAnyVariable(comparisonLoopVarExpr, nonFinalVariables)) return null;
      }
      PsiType loopVarExprType = comparisonLoopVarExpr.getType();
      if (!hasKnownComparableType(comparison, loopVarExprType)) return null;

      PsiExpression extremumInitializer = extremum.getInitializer();
      if (!ExpressionUtils.isEvaluatedAtCompileTime(extremumInitializer)) return null;
      return new PrimitiveExtremumTerminal(comparison.isMax(), terminalBlock, comparisonLoopVarExpr, extremum, extremumInitializer);
    }
@Nullable
    private static PrimitiveExtremumTerminal extract(@NotNull PsiExpression condition,
                                                     PsiStatement @NotNull [] statements,
                                                     @NotNull TerminalBlock terminalBlock,
                                                     @Nullable List<? extends PsiVariable> nonFinalVariables,
                                                     boolean isNegated)