public Iterator<Traverser.Admin<S>> attach(final Iterator<Traverser.Admin<S>> iterator, final Graph graph) {
        return IteratorUtils.map(iterator, traverser -> {
            traverser.setSideEffects(this.getTraversal().getSideEffects());   // necessary to ensure no NPE
            if (this.attachElements && (traverser.get() instanceof Attachable) && !(traverser.get() instanceof Property))
                traverser.set((S) ((Attachable<Element>) traverser.get()).attach(Attachable.Method.get(graph)));
            return traverser;
        });
    }
@author Marko A. Rodriguez (http://markorodriguez.com)
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/ComputerResultStep.java