def recursive_rename_keys(old_dict: dict, old_to_new_map: dict):
    """
    Given a nested dictionary 'old_dict', recursively update all keys according to old_to_new_map
    """

    if not isinstance(old_dict, dict):
        return old_dict

    new_dict = {}
    for key, value in old_dict.items():
        if key in old_to_new_map:
            new_dict[old_to_new_map[key]] = recursive_rename_keys(value, old_to_new_map)
        else:
            new_dict[key] = recursive_rename_keys(value, old_to_new_map)

    return new_dict