BFS to populate active nodes.