code: def data(self, root, preserve_root=False):
          '''Convert etree.Element into a dictionary'''
          # If preserve_root is False, return the root element. This is easiest
          # done by wrapping the XML in a dummy root element that will be ignored.
          if preserve_root:
              new_root = root.makeelement('dummy_root', {})
              new_root.insert(0, root)
              root = new_root
  
          # If no children, just return the text
          children = [node for node in root if isinstance(node.tag, basestring)]
          if len(children) == 0:
              return self._fromstring(root.text)
  
          # Element names become object properties
          count = Counter(child.tag for child in children)
          result = self.dict()
          for child in children:
              if count[child.tag] == 1:
                  result[child.tag] = self.data(child)
              else:
                  result.setdefault(child.tag, self.list()).append(self.data(child))
  
          return resulf data(self, root, preserve_root=False):
          '''Convert etree.Element into a dictionary'''
          # If preserve_root is False, return the root element. This is easiest
          # done by wrapping the XML in a dummy root element that will be ignored.
          if preserve_root:
              new_root = root.makeelement('dummy_root', {})
              new_root.insert(0, root)
              root = new_root
  
          # If no children, just return the text
          children = [node for node in root if isinstance(node.tag, basestring)]
          if len(children) == 0:
              return self._fromstring(root.text)
  
          # Element names become object properties
          count = Counter(child.tag for child in children)
          result = self.dict()
          for child in children:
              if count[child.tag] == 1:
                  result[child.tag] = self.data(child)
              else:
                  result.setdefault(child.tag, self.list()).append(self.data(child))
  
          return result
docs: Convert etree.Element into a dictionary