Iterative and recursive BFS and DFS implementations for tree nodes