add index to id to make it unique wrt ids

def append_index_id(id, ids):
    """
    add index to id to make it unique wrt ids
    """
    index = 1
    mod = '%s_%s' % (id, index)
    while mod in ids:
        index += 1
        mod = '%s_%s' % (id, index)
    ids.append(mod)
    return mod, ids