Also, keep in mind, this change does nothing about the risk of another client constantly adding nodes. That could race with this before and after. This is about trying to remove a node that has children - it looks like the node has no children, we try to remove it, boom it has a child. It doesn't affect a race off adding and removing children nodes. It just makes the method consistent in working how it was intended rather than this odd race fail you can get.
That doesn't mean the clean method itself could not be re implemented or something, but that's another issue.