static IterableIterator> allSpreads(final int toSpread, final int buckets) { class StackEntry { int remaining, n, take; L collecting; LL out; int position; L step(L stack) { if (position == 0) { if (l(collecting) >= n-1) { result = listPlus(cloneList(collecting), remaining)); dropLast(stack); ret result; } else if (position == 1) { if (take <= remaining) { collecting.add(take); new StackEntry e; e.remaining = remaining-take; e.n = n; e.collecting = collecting; stack.add(e); } else { if (empty(stack)) ret endMarker(); dropLast(stack); } } else if (e.position == 2) { removeLast(e.collecting); e.take++; e.position = 1; } } } final new L stack; ret iff(new F0 { while true { ping(); L result = last(stack).step(stack); if (result != null) ret result; } }); }