[9.18] Try to cleanup all parents, but skip those with children
The parent->down was not checked when sending the parent to the prune tree, thus sending a node that would be later rejected to the pruning. On top of that, is_leaf() was called in error, skipping deletion of the parents that have siblings.
Closes #4596 (closed)