private static Pair<List<UndoableAction>, List<UndoableAction>> separateLocalAndNonLocalActions(@NotNull List<? extends UndoableAction> actions,
                                                                                                  @NotNull DocumentReference affectedDocument) {
    List<UndoableAction> localActions = new SmartList<>();
    List<UndoableAction> nonLocalActions = new SmartList<>();
    for (UndoableAction action : actions) {
      DocumentReference[] affectedDocuments = action.getAffectedDocuments();
      if (affectedDocuments != null && affectedDocuments.length == 1 && affectedDocuments[0].equals(affectedDocument)) {
        localActions.add(action);
      }
      else {
        nonLocalActions.add(action);
      }
    }

    return new Pair<>(localActions, nonLocalActions);
  }
private static Pair<List<UndoableAction>, List<UndoableAction>> separateLocalAndNonLocalActions(@NotNull List<? extends UndoableAction> actions,
                                                                                                  @NotNull DocumentReference affectedDocument)