Added some more paranoia to subtree iteration.