Strip ids_to_strip from the end ids.

def strip_ids(ids, ids_to_strip):
  """Strip ids_to_strip from the end ids."""
  ids = list(ids)
  while ids and ids[-1] in ids_to_strip:
    ids.pop()
  return ids