def METHOD_NAME(taxa, firstid):
    tag_to_id = {}
    first_id = firstid
    last_id = None
    id = first_id
    for taxon in taxa:
        if not "ott_id" in taxon:
            taxon["ott_id"] = id
            tag_to_id[taxon["tag"]] = id
            last_id = id
            id += 1
            p = taxon.get("parent_tag")
            if p != None:
                taxon["parent"] = tag_to_id[p]
    return tag_to_id