The layout is controlled by moving the nodes closest to the tree's root node. When one of these nodes is moved horizontally to the other side of the root, all of its children will be sent to Layout.doLayout with a new direction, causing text to always be moved outwards from the root.
When a node is deleted the CommandHandler.deletesTree property ensures that all of its children are deleted with it. When a node is dragged the DraggingTool.dragsTree property ensures that all its children are dragged with it. Both of these are set during the the Diagram's initalization.Diagram Model saved in JSON format: