static <T> void closeIterator(final Iterator<T> iterator) {
        if (iterator instanceof AutoCloseable) {
            try {
                ((AutoCloseable) iterator).close();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
Wraps an existing {@code Iterator} in a {@code CloseableIterator}. If the {@code Iterator} is already of that
type then it will simply be returned as-is.
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/CloseableIterator.java