It checks for children in the model "has_ancestry :orphan_strategy => :restrict", which throws an AncestryException when there are children.
This is just the handler to display errors nicely in the UI, since AncestryException is displayed as a 500.