Major refactoring of tree traversal exercises