public boolean replaceOnStacks(@NotNull UndoableGroup group, @NotNull UndoableGroup newGroup) {
    boolean hasAffectedItems = false;

    for (UndoRedoList<UndoableGroup> stack : getAffectedStacks(group)) {
      for (var stackIterator = stack.listIterator(); stackIterator.hasNext(); ) {
        var currentGroup = stackIterator.next();
        if (currentGroup != group) continue;

        stackIterator.set(newGroup);
        hasAffectedItems = true;
      }
    }

    return hasAffectedItems;
  }
public boolean replaceOnStacks(@NotNull UndoableGroup group, @NotNull UndoableGroup newGroup)