code: def ensure_soup(value, parser=None):
      
      if isinstance(value, BeautifulSoup):
          return value.find()
      if isinstance(value, Tag):
          return value
      if isinstance(value, list):
          return [
              ensure_soup(item, parser=parser)
              for item in value
          ]
      parsed = BeautifulSoup(value, features=parser)
      return parsed.find()
docs: Coerce a value (or list of values) to Tag (or list of Tag).
  
      :param value: String, BeautifulSoup, Tag, or list of the above
      :param str parser: Parser to use; defaults to BeautifulSoup default
      :return: Tag or list of Tags