code: def clone_bs4_elem(el):
      
      if isinstance(el, NavigableString):
          return type(el)(el)
  
      copy = Tag(None, el.builder, el.name, el.namespace, el.nsprefix)
      # work around bug where there is no builder set
      # https://bugs.launchpad.net/beautifulsoup/+bug/1307471
      copy.attrs = dict(el.attrs)
      for attr in ('can_be_empty_element', 'hidden'):
          setattr(copy, attr, getattr(el, attr))
      for child in el.contents:
          copy.append(clone_bs4_elem(child))
      return copy
docs: Clone a bs4 tag before modifying it.
  
      Code from `http://stackoverflow.com/questions/23057631/clone-element-with
      -beautifulsoup`