def get_unique_name(existing, initial):
    """Get a name either equal to initial or of the form initial_N, for some
    integer N, that is not in the set existing.


    :param existing: Set of names that must not be chosen.
    :param initial: Name, or name prefix, to use"""
    if initial not in existing:
        return initial
    for i in range(len(existing) + 1):
        test = f"{initial}_{i + 1}"
        if test not in existing:
            return test
    assert False