def METHOD_NAME(mapping, key=None):
    """Recursively convert 'multi_field' type (deprecated since version 0.9) to
    'string' in an Elastic mapping. The field named the same as the property is
    no longer necessary since the top-level property becomes the default in
    versions >=1.0.
    See: https://www.elastic.co/guide/en/elasticsearch/reference/1.7/_multi_fields.html
    Transforms:
        "city": {
            "fields": {
                "city":  {"type": "string", "index": "analyzed"},
                "exact": {"type": "string", "index": "not_analyzed"},
            },
            "type": "multi_field"
        }
    To:
        "city": {
            "fields": {
                "exact": {"type": "string", "index": "not_analyzed"}
            },
            "type": "string"
        }
    """
    if isinstance(mapping, dict):
        if "fields" in mapping and mapping.get("type") == "multi_field":
            mapping = mapping.copy()
            if key is None or key not in mapping["fields"]:
                raise ValueError(f"'multi_field' property {key!r} is missing "
                                 f"the 'default' field: {mapping}")
            mapping.update(mapping["fields"].pop(key))
            if mapping.get("index") == "analyzed":
                # {"index": "analyzed"} is the default
                del mapping["index"]
        return {k: METHOD_NAME(v, k) for k, v in mapping.items()}
    elif isinstance(mapping, (tuple, list, set)):
        return [METHOD_NAME(v) for v in mapping]
    else:
        return mapping