pre-post order tree traversal switch