def count_leafnodes(d:dict) -> int:
    """Count the number of nodes with leaves in a nested dictionary.
    """
    n = 0
    if d:
        m = 0
        for k,v in d.items():
            if type(v) is dict:
                m += count_leafnodes(v)
        return n + max(m,1)
    return n