boolean (@NotNull UndoableGroup group, @NotNull UndoableGroup newGroup) { boolean hasAffectedItems = false; for (LinkedList<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; }