Deleting child nodes in tree

i m trying to delete all the child node if parent is deleted for reference i m using

but if i delete a parent node in this the child remains in the diagram is there a way to delete child without looping over the connected nodes?

If you right click a node and hit the “Remove Department” button, it removes the node and all children. You can see that code in the sample by looking at the context menu button labeled “Remove Department.” Basically, it calls Node.findTreeParts and removes that collection.