ImmutableActionChangeRange[] moveToStackTop(@NotNull DocumentReference reference, @NotNull Map<Integer, ? extends ActionChangeRange> rangesToMove) {
    UndoRedoList<ImmutableActionChangeRange> stack = getStack(reference);
    ImmutableActionChangeRange[] affected = getAffectedRanges(stack, rangesToMove);
    if (affected == null) {
      return null;
    }
    if (!moveToEnd(affected, rangesToMove.keySet())) {
      throw new IllegalStateException("Cannot move to top: " + rangesToMove);
    }
    for (int i = 0; i < affected.length; i++) {
      stack.removeLast();
    }
    stack.addAll(Arrays.asList(affected));
    trimInvalid(stack);

    return affected;
  }
ImmutableActionChangeRange[] moveToStackTop(@NotNull DocumentReference reference, @NotNull Map<Integer, ? extends ActionChangeRange> rangesToMove)