@Override
    public Map<Object, Traverser.Admin<S>> nextBarrier() throws NoSuchElementException {
        final Map<Object, Traverser.Admin<S>> map = null != this.barrier ? this.barrier : new HashMap<>();
        while (this.starts.hasNext()) {
            final Traverser.Admin<S> traverser = this.starts.next();
            final Object object;
            boolean productive;
            if (null != this.dedupLabels) {
                object = new ArrayList<>(this.dedupLabels.size());
                for (final String label : this.dedupLabels) {
                    final TraversalProduct product = TraversalUtil.produce((S) this.getSafeScopeValue(Pop.last, label, traverser), this.dedupTraversal);
                    if (!product.isProductive()) break;
                    ((List) object).add(product.get());
                }

                productive = ((List) object).size() == this.dedupLabels.size();
            } else {
                final TraversalProduct product = TraversalUtil.produce(traverser, this.dedupTraversal);
                productive = product.isProductive();
                object = productive ? product.get() : null;
            }

            if (productive) {
                if (!map.containsKey(object)) {
                    traverser.setBulk(1L);

                    // DetachedProperty and DetachedVertexProperty both have a transient for the Host element. that causes
                    // trouble for olap which ends up requiring the Host later. can't change the transient without some
                    // consequences: (1) we break gryo formatting and io tests start failing (2) storing the element with
                    // the property has the potential to bloat detached Element instances as it basically stores that data
                    // twice. Not sure if it's smart to change that at least in 3.4.x and not without some considerable
                    // thought as to what might be major changes. To work around the problem we will detach properties as
                    // references so that the parent element goes with it. Also, given TINKERPOP-2318 property comparisons
                    // have changed in such a way that allows this to work properly
                    if (this.onGraphComputer) {
                        if (traverser.get() instanceof Property)
                            traverser.set(ReferenceFactory.detach(traverser.get()));
                        else
                            traverser.set(DetachedFactory.detach(traverser.get(), true));
                    } else {
                        traverser.set(traverser.get());
                    }
                    map.put(object, traverser);
                }
            }
        }

        this.barrier = null;
        this.barrierIterator = null;
        return map;
    }
@author Marko A. Rodriguez (http://markorodriguez.com)
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/DedupGlobalStep.java