def recursive_flatten_metadata(tree_metadata, flat_metadata = {}, metadata_path = [], path_index = 0)
      unless tree_metadata.empty?
        tree_metadata.each do |key, value|
          metadata_path[path_index] = key
          if value.respond_to?(:has_key?)
            recursive_flatten_metadata(value, flat_metadata, metadata_path, path_index + 1)
          else
            flat_path = flatten_metadata_path(metadata_path)
            flat_metadata[flat_path] = value
          end
        end
        metadata_path.pop
        raise "Unexpected path" unless metadata_path.size == path_index
      end
      return flat_metadata
    end
def recursive_flatten_metadata(tree_metadata, flat_metadata = {}, metadata_path = [], path_index = 0)
      unless tree_metadata.empty?
        tree_metadata.each do |key, value|
          metadata_path[path_index] = key
          if value.respond_to?(:has_key?)
            recursive_flatten_metadata(value, flat_metadata, metadata_path, path_index + 1)
          else
            flat_path = flatten_metadata_path(metadata_path)
            flat_metadata[flat_path] = value
          end
        end
        metadata_path.pop
        raise "Unexpected path" unless metadata_path.size == path_index
      end
      return flat_metadata
    end
Recursively flattens metadata.

 === Parameters
 tree_metadata(Hash):: metadata to flatten
 flat_metadata(Hash):: flattened metadata or {}
 metadata_path(Array):: array of metadata path elements or []
 path_index(int):: path array index to update or 0

 === Returns
 flat_metadata(Hash):: flattened metadata