def _harvest_tree(self, tree, version=1):
    """Populates object members from the data in the tree Element."""
    qname, elements, attributes = self.__class__._get_rules(version)
    for element in tree:
      if elements and element.tag in elements:
        definition = elements[element.tag]
        # If this is a repeating element, make sure the member is set to a 
        # list.
        if definition[2]:
          if getattr(self, definition[0]) is None:
            setattr(self, definition[0], [])
          getattr(self, definition[0]).append(_xml_element_from_tree(element,
              definition[1], version))
        else:
          setattr(self, definition[0], _xml_element_from_tree(element, 
              definition[1], version))
      else:
        self._other_elements.append(_xml_element_from_tree(element, XmlElement,
                                                           version))
    for attrib, value in tree.attrib.iteritems():
      if attributes and attrib in attributes:
        setattr(self, attributes[attrib], value)
      else:
        self._other_attributes[attrib] = value
    if tree.text:
      self.text = tree.text
dataset/ETHPy150Open CollabQ/CollabQ/vendor/atom/core.py/XmlElement._harvest_tree/original