public static <S, E> TraversalProduct produce(final Traverser.Admin<S> traverser, final Traversal.Admin<S, E> traversal) {
        if (null == traversal) {
            return new TraversalProduct(traverser.get());
        } else {
            prepare(traverser, traversal);
            try {
                if (traversal.hasNext()) {
                    return new TraversalProduct(traversal.next());
                } else {
                    return TraversalProduct.UNPRODUCTIVE;
                }
            } finally {
                CloseableIterator.closeIterator(traversal);
            }
        }
    }
@author Marko A. Rodriguez (http://markorodriguez.com)
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalUtil.java