def _shift_parts(family_parts, subfamily_parts, stop_fn):
  """Iterate over subfamily parts, removing from
  subfamily and appending to family, until stop_fn(part)
  returns true.  If subfamily_parts is empty, add
  'Regular'.  This works because for both original and
  wws subfamilies the order of parts is such that all
  parts that fail the stop_fn precede any that pass.
  Does not modify the input parts lists."""

  result_family_parts = family_parts[:]
  limit = len(subfamily_parts)
  i = 0
  while i < limit:
    part = subfamily_parts[i]
    if stop_fn(part):
      break
    result_family_parts.append(part)
    i += 1
  result_subfamily_parts = subfamily_parts[i:]
  if not result_subfamily_parts:
    result_subfamily_parts.append('Regular')
  return result_family_parts, result_subfamily_parts