Make sure every vCard in the dictionary has a unique filename.

def DedupVcardFilenames(vcard_dict):
    """Make sure every vCard in the dictionary has a unique filename."""
    remove_keys = []
    add_pairs = []
    for k, v in vcard_dict.items():
        if not len(v) > 1:
            continue
        for idx, vcard in enumerate(v):
            fname, ext = os.path.splitext(k)
            fname = '{}-{}'.format(fname, idx + 1)
            fname = fname + ext
            assert fname not in vcard_dict
            add_pairs.append((fname, vcard))
        remove_keys.append(k)

    for k, v in add_pairs:
        vcard_dict[k].append(v)

    for k in remove_keys:
        vcard_dict.pop(k)

    return vcard_dict