Simple BFS in JavaScript for trees.