public static Vertex addTo(final Graph graph, final DetachedVertex detachedVertex) {
final Vertex vertex = graph.addVertex(T.id, detachedVertex.id(), T.label, detachedVertex.label());
detachedVertex.properties.entrySet().forEach(kv ->
kv.getValue().forEach(property -> {
final VertexProperty vertexProperty = (VertexProperty) property;
final List<Object> propsOnProps = new ArrayList<>();
vertexProperty.iterators().hiddenPropertyIterator().forEachRemaining(h -> {
propsOnProps.add(Graph.Key.hide(h.key()));
propsOnProps.add(h.value());
});
vertexProperty.iterators().propertyIterator().forEachRemaining(h -> {
propsOnProps.add(h.key());
propsOnProps.add(h.value());
});
propsOnProps.add(T.id);
propsOnProps.add(vertexProperty.id());
vertex.property(kv.getKey(), property.value(), propsOnProps.toArray());
})
);
return vertex;