def nested_docfield_unwrapper(field: str, hitdict, value: dict) -> dict:
    """ Unwraps the JSON for nested fields in a document that was returned from a search """
    if isinstance(value, dict):
        for (sf, sf_v) in value.items():
            nested_docfield_unwrapper(field + '.' + sf, hitdict, sf_v)
    else:
        if field not in hitdict:
            hitdict[field] = value
    return hitdict