def cast_nested_dict(d, original_type, new_type):
    """Cast items in a nested dict to a new type.

    Converts all leaves of type `original_type` to type `new_type`

    Args:
        d (dict): nested dict to cast
        original_type (type): old type to convert
        new_type (type): new type to apply to leaf nodes

    Returns:
        dict

    Examples:
    >>> cast_nested_dict({"hello": 0.70, "hey": {"sup": 1}}, float, int)
    {'hello': 0, 'hey': {'sup': 1}}

    """
    result = dict()
    for k, v in d.items():
        if isinstance(v, dict):
            result[k] = cast_nested_dict(
                v, original_type=original_type, new_type=new_type
            )
        elif isinstance(v, original_type):
            result[k] = new_type(v)
        else:
            result[k] = v
    return result