docs: def etree(self, data, root=None):
          '''Convert data structure into a list of etree.Element'''
          result = self.list() if root is None else root
          if isinstance(data, (self.dict, dict)):
              for key, value in data.items():
                  value_is_list = isinstance(value, (self.list, list))
                  value_is_dict = isinstance(value, (self.dict, dict))
                  # Add attributes and text to result (if root)
                  if root is not None:
                      # Handle attribute prefixes (BadgerFish)
                      if self.attr_prefix is not None:
                          if key.startswith(self.attr_prefix):
                              key = key.lstrip(self.attr_prefix)
                              # @xmlns: {$: xxx, svg: yyy} becomes xmlns="xxx" xmlns:svg="yyy"
                              if value_is_dict:
                                  raise ValueError('XML namespaces not yet supported')
                              else:
                                  result.set(key, self._tostring(value))
                              continue
                      # Handle text content (BadgerFish, GData)
                      if self.text_content is not None:
                          if key == self.text_content:
                              result.text = self._tostring(value)
                              continue
                      # Treat scalars as text content, not children (GData)
                      if self.attr_prefix is None and self.text_content is not None:
                          if not value_is_dict and not value_is_list:
                              result.set(key, self._tostring(value))
                              continue
                  # Add other keys as one or more children
                  values = value if value_is_list else [value]
                  for value in values:
                      elem = self.element(key)
                      if elem is None:
                          continue
                      result.append(elem)
                      # Treat scalars as text content, not children (Parker)
                      if not isinstance(value, (self.dict, dict, self.list, list)):
                          if self.text_content:
                              value = {self.text_content: value}
                      self.etree(value, root=elem)
          else:
              if self.text_content is None and root is not None:
                  root.text = self._tostring(data)
              else:
                  elem = self.element(self._tostring(data))
                  if elem is not None:
                      result.append(elem)
          return result