public static DetachedElement detach(final Element element, final boolean withProperties) {
        if (element instanceof Vertex)
            return detach((Vertex) element, withProperties);
        else if (element instanceof Edge)
            return detach((Edge) element, withProperties);
        else if (element instanceof VertexProperty)
            return detach((VertexProperty) element, withProperties);
        else
            throw new IllegalArgumentException("The provided argument is an unknown element: " + element + ':' + element.getClass());
    }
@author Marko A. Rodriguez (http://markorodriguez.com)
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedFactory.java