@Override
    protected boolean filter(final Traverser.Admin<S> traverser) {
        if (this.onGraphComputer && !this.executingAtMaster) return true;
        traverser.setBulk(1L);
        if (null == this.dedupLabels) {
            final TraversalProduct product = TraversalUtil.produce(traverser, this.dedupTraversal);
            return product.isProductive() && this.duplicateSet.add(product.get());
        } else {
            final List<Object> objects = new ArrayList<>(this.dedupLabels.size());
            for (String label : dedupLabels) {
                final TraversalProduct product = TraversalUtil.produce((S) this.getSafeScopeValue(Pop.last, label, traverser), this.dedupTraversal);
                if (!product.isProductive()) break;
                objects.add(product.get());
            }

            // the object sizes must be equal or else it means a by() wasn't productive and that path will be filtered
            return objects.size() == dedupLabels.size() && duplicateSet.add(objects);
        }
    }
@author Marko A. Rodriguez (http://markorodriguez.com)
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/DedupGlobalStep.java