Just some tree traversal code.