static ItIt ai_dropTrailingPhrases_repeat(S s, Collection phrases) { final Set set = asCISet(phrases); final new HashSet seen; // Make pool of iterators final L> pool = ll_linkedList((Iterator) ai_dropTrailingPhrases(s, set)); ret iteratorFromFunction(func -> S { while ping (!empty(pool)) { Iterator it = first(pool); if (!it.hasNext()) continue with removeFirst(pool); // Check if seen already if (!seen.add(it)) continue; // found entry - return and schedule for further analysis S entry = it.next(); pool.add(ai_dropTrailingPhrases(entry, set)); ret entry; } null; }); }