Iterator<Item> (@Nullable Item start, boolean fwd, boolean wrap) { if (!wrap || start == null) return iterate(start, fwd); return new JBIterator<>() { boolean wrapped = false; Iterator<Item> it = iterate(start, fwd); @Override protected Item nextImpl() { if (it.hasNext()) return it.next(); if (wrapped) return stop(); wrapped = true; it = JBIterator.from(iterate(null, fwd)).takeWhile(item -> item != start); return it.hasNext() ? it.next() : stop(); } }; }