public static <K,V> ConcurrentHashMap<K,V> clone(final ConcurrentHashMap<K,V> map) {
        final ConcurrentHashMap<K, V> result = new ConcurrentHashMap<>(map.size());

        for (Map.Entry<K, V> entry : map.entrySet()) {
            V clonedValue;
            if (entry.getValue() instanceof Set) {
                clonedValue = (V) ConcurrentHashMap.newKeySet();
                ((Set) clonedValue).addAll((Set) entry.getValue());
            } else if (entry.getValue() instanceof ArrayList) {
                clonedValue = (V)((ArrayList) entry.getValue()).clone();
            } else {
                clonedValue = entry.getValue();
            }

            result.put(entry.getKey(), clonedValue);
        }

        return result;
    }
Clones a given {@code ConcurrentHashMap} by creating a new map and copying all entries from the original map.
If the value of an entry is a {@code Set} or an {@code ArrayList}, a deep copy of the value is created.
Otherwise, the value is copied as is.
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/CollectionUtil.java