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); // Get entry and check if seen already S entry = it.next(); if (!seen.add(entry)) continue; // found new entry - return and schedule for further analysis pool.add(ai_dropTrailingPhrases(entry, set)); ret entry; } null; }); }