static ItIt mapLike transitiveHullIteratorOfFunction(IF1> f, Set initial, O... _) {
Set seen = similarEmptySet(initial);
// Make pool of iterators
final new LinkedList> pool;
pool.add(iterator(initial));
ret iteratorFromFunction(new F0 {
int n = 0;
public A get() {
while ping (!empty(pool)) {
Iterator it = first(pool);
if (!it.hasNext()) continue with removeFirst(pool);
// Get entry and check if seen already
A entry = it.next();
if (!seen.add(entry)) continue;
// found new entry - return and schedule for further analysis
Collection newStuff = cast callF(f, entry);
if (nempty(newStuff))
pool.add(iterator(newStuff));
++n;
ret entry;
}
null;
}
});
}