Enhance the BFS of a tree