public default <E2> void forEachRemaining(final Class<E2> endType, final Consumer<E2> consumer) {
        try {
            while (true) {
                consumer.accept((E2) next());
            }
        } catch (final NoSuchElementException ignore) {

        }  finally {
            CloseableIterator.closeIterator(this);
        }
    }
A traversal can be rewritten such that its defined end type E may yield objects of a different type.
This helper method allows for the casting of the output to the known the type.

@param endType  the true output type of the traversal
@param consumer a {@link Consumer} to process each output
@param <E2>     the known output type of the traversal
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java