def count_nodes(d:dict) -> int:
    """Count the number of nodes (leaves included) in a nested dictionary.
    """
    n = len(d.keys())
    for k,v in d.items():
        if type(v) is dict:
            n += count_nodes(v)
    return n