public static Metadata cloneMetadata(Metadata m) {
        Metadata clone = new Metadata();

        for (String n : m.names()) {
            if (!m.isMultiValued(n)) {
                clone.set(n, m.get(n));
            } else {
                String[] vals = m.getValues(n);
                for (String val : vals) {
                    clone.add(n, val);
                }
            }
        }
        return clone;
    }
Does a deep clone of a Metadata object.
tika-core/src/main/java/org/apache/tika/utils/ParserUtils.java