tree and treenode class that handles BFS and DFS