bfs in a tree