code: def _get_or_update_parent(key, val, to_str, parent=None, **options):
      
      elem = ET.Element(key)
  
      vals = val if anyconfig.utils.is_iterable(val) else [val]
      for val_ in vals:
          container_to_etree(val_, parent=elem, to_str=to_str, **options)
  
      if parent is None:  # 'elem' is the top level etree.
          return elem
  
      parent.append(elem)
      return parent
docs: :param key: Key of current child (dict{,-like} object)
      :param val: Value of current child (dict{,-like} object or [dict{,...}])
      :param to_str: Callable to convert value to string
      :param parent: XML ElementTree parent node object or None
      :param options: Keyword options, see :func:`container_to_etree`