Fix a warning on undoing flattening a group
When updates are issued in the middle of layer addition/removal it may happen that some updates will never reach the root node, which is a bug. And the warning told us about that.
The patch moves the updates into a separate command that emits them in a batch after all node modifications are finished.