private static void extractHeadCommonParts(PsiStatement @NotNull [] thenBranch,
                                               PsiStatement @NotNull [] elseBranch,
                                               boolean isOnTheFly,
                                               LocalEquivalenceChecker equivalence,
                                               int minStmtCount,
                                               List<PsiLocalVariable> conditionVariables,
                                               List<? super ExtractionUnit> headCommonParts,
                                               Set<? super PsiVariable> extractedVariables,
                                               Set<? super PsiVariable> notEquivalentVariableDeclarations) {
      if (!isSimilarHeadStatements(thenBranch)) {
        for (int i = 0; i < minStmtCount; i++) {
          PsiStatement thenStmt = thenBranch[i];
          PsiStatement elseStmt = elseBranch[i];
          ExtractionUnit unit = extractHeadCommonStatement(thenStmt, elseStmt, conditionVariables, equivalence);
          if (unit == null) break;
          if (!isOnTheFly && unit.haveSideEffects()) break;
          boolean dependsOnVariableWithNonEquivalentInitializer = VariableAccessUtils.collectUsedVariables(thenStmt).stream()
            .filter(var -> var instanceof PsiLocalVariable)
            .anyMatch(var -> notEquivalentVariableDeclarations.contains(var));

          if (dependsOnVariableWithNonEquivalentInitializer) {
            break;
          }
          PsiVariable variable = extractVariable(unit.getThenStatement());
          if (variable != null) {
            extractedVariables.add(variable);
            if (!unit.isEquivalent()) {
              notEquivalentVariableDeclarations.add(variable);
            }
          }
          headCommonParts.add(unit);
        }
      }
    }
private static void extractHeadCommonParts(PsiStatement @NotNull [] thenBranch,
                                               PsiStatement @NotNull [] elseBranch,
                                               boolean isOnTheFly,
                                               LocalEquivalenceChecker equivalence,
                                               int minStmtCount,
                                               List<PsiLocalVariable> conditionVariables,
                                               List<? super ExtractionUnit> headCommonParts,
                                               Set<? super PsiVariable> extractedVariables,
                                               Set<? super PsiVariable> notEquivalentVariableDeclarations)