Once we have multiple res_ids, this can be determined by lookup in a dictionary of identifier->res_id. Passing it around through the rest of the functions will save lookups as long as the original call uses the right res_id.