private @NotNull Pair<Integer, Set<CommitId>> getRedCommitsAndSavedRedIndex(@NotNull List<? extends Commit> savedLog,
                                                                              @NotNull Collection<? extends CommitId> previousRefs,
                                                                              @NotNull List<? extends Commit> firstBlock,
                                                                              @NotNull Collection<? extends CommitId> newRefs) {
    Set<CommitId> startRedCommits = new HashSet<>(previousRefs);
    startRedCommits.removeAll(newRefs);
    Set<CommitId> startGreenNodes = new HashSet<>(newRefs);
    for (Commit commit : firstBlock) {
      startGreenNodes.add(commit.getId());
      startGreenNodes.addAll(commit.getParents());
    }
    RedGreenSorter<CommitId, Commit> sorter = new RedGreenSorter<>(startRedCommits, startGreenNodes, savedLog);
    int saveRegIndex = sorter.getFirstSaveIndex();

    return new Pair<>(saveRegIndex, sorter.getAllRedCommit());
  }
private @NotNull Pair<Integer, Set<CommitId>> getRedCommitsAndSavedRedIndex(@NotNull List<? extends Commit> savedLog,
                                                                              @NotNull Collection<? extends CommitId> previousRefs,
                                                                              @NotNull List<? extends Commit> firstBlock,
                                                                              @NotNull Collection<? extends CommitId> newRefs)