def add_subdict(d, persons, key, value):
    """Add nested subdict to person entry in a dict if it exists,
    otherwise create.
    """
    for p in persons:
        try:
            try:
                d[p][key] += value
            except KeyError:
                d[p].update({key: value})
        except KeyError:
            d[p] = {key: value}
    return d