Simplification of the BFS generator following the comments on the
first PR (using lists only).