BreadthFirstSearchIterator: optimizations when the iteration is restricted to
a subset