public GraphSONTypeIdResolver addCustomType(final String name, final Class clasz) {
        if (Tree.class.isAssignableFrom(clasz)) {
            // there is a special case for Tree which extends a Map, but has only 1 parametrized type,
            // and for which creating a default type is failing because it may fall into a
            // a self-referencing never-ending loop. Temporarily we force Tree<Element>
            // which should cover all the usage TinkerPop would do of the Trees anyway.
            idToType.put(name, TypeFactory.defaultInstance().constructType(new TypeReference<Tree<? extends Element>>() {}));
        } else {
            idToType.put(name, TypeFactory.defaultInstance().constructType(clasz));
        }
        typeToId.put(clasz, name);
        return this;
    }
Provides quick lookup for Type deserialization extracted from the JSON payload. As well as the Java Object to types
compatible for the version 2.0 of GraphSON.

@author Kevin Gallardo (https://kgdo.me)
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTypeIdResolver.java