an exercise in binary tree traversal