public Object getKey(final Object kv) {
        // remotes return LinkedHashMap and embedded returns Map.Entry :/
        if (kv instanceof Map.Entry)
            return ((Map.Entry) kv).getKey();
        else if (kv instanceof Map)
            return ((Map) kv).keySet().iterator().next();
        else
            throw new IllegalStateException("Returned value should be a Map or Map.Entry but got: " + kv.getClass().getName());
    }
@author Marko A. Rodriguez (http://markorodriguez.com)
@author Stephen Mallette (http://stephen.genoprime.com)
gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/OrderTest.java