Package ptree
source code
Two drop-in replacements for xml.etree.ElementTree with elements that 
  automatically keep track of parent pointers.  This package defines two 
  objects, each of which provide the same interface as the 
  xml.etree.ElementTree module:
  
    - 
      ptree.ParentedTree: Each element keeps track of a single parent 
      pointer, returned by the element's `parent()` method.  Elements may 
      have at most one parent; i.e., subtrees may not be shared. Any 
      attempt to do use a single element as a child for multiple parents 
      will generate a ValueError.
    
- 
      ptree.MultiParentedTree: Each element keeps track of a list of parent
      pointers, returned by the element's `parents()` method. Elements may 
      have zero or more parients; i.e., subtrees may be shraed.  If a 
      single Element is used as multiple children of the same parent, then 
      that parent will appear multiple times in the parents list.
    
Aside from addition of parent pointers, these two objects should act 
  identically to xml.etree.ElementTree.
  Note: Mixing of etree implementations is not supported.  I.e., you 
  should never construct a tree that combines elements from ParentedTree 
  with elements from MultiParentedTree, or elements from either of these 
  implementations with elements from any other implementation.  Doing so 
  may result in incorrect parent pointers and ValueError exceptions.
    |  | ParentedTree = ElementTreeImplementation(_ParentedElement) | 
    |  | MultiParentedTree = ElementTreeImplementation(_MultiParentedEl... | 
    |  | __package__ = 'ptree' | 
| MultiParentedTree
   
    Value:| 
ElementTreeImplementation(_MultiParentedElement)
 | 
 |