@Override
    public TraverserSet<S> nextBarrier() throws NoSuchElementException {
        this.processAllStarts();
        if (this.traverserSet.isEmpty())
            throw FastNoSuchElementException.instance();
        else {
            final TraverserSet<S> temp = (TraverserSet<S>) this.traversal.getTraverserSetSupplier().get();
            IteratorUtils.removeOnNext(this.traverserSet.iterator()).forEachRemaining(t -> {
                DetachedFactory.detach(t, true); // this should be dynamic
                temp.add(t);
            });
            return temp;
        }
    }
@author Marko A. Rodriguez (http://markorodriguez.com)
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/CollectingBarrierStep.java