code: def remove_path_segments(segments, removes):
      if segments == ['']:
          segments.append('')
      if removes == ['']:
          removes.append('')
      if segments == removes:
          ret = []
      elif len(removes) > len(segments):
          ret = segments
      else:
          removes2 = list(removes)
          if len(removes) > 1 and removes[0] == '':
              removes2.pop(0)
          if removes2 and removes2 == segments[-1 * len(removes2):]:
              ret = segments[:len(segments) - len(removes2)]
              if removes[0] != '' and ret:
                  ret.append('')
          else:
              ret = segments
      return ret