Perhaps simpler is to just pass the whole metadata around,  and then do the further down the line, with simple calls to:

```javascript
function _get_metadata_key(metadata, key, mime) {
    var mime_md = metadata[mime];
    // mime-specific higher priority
    if (mime_md && mime_md[key] !== undefined) {
        return mime_md[key];
    }
    // fallback on global
    return metadata[key];
}
```