code: def _backtrace(elt, dom):
      '''Return a "backtrace" from the given element to the DOM root,
      in XPath syntax.
      '''
      s = ''
      while elt != dom:
          name, parent = elt.nodeName, elt.parentNode
          if parent is None: break
          matches = [ c for c in _child_elements(parent) 
                          if c.nodeName == name ]
          if len(matches) == 1:
              s = '/' + name + s
          else:
              i = matches.index(elt) + 1
              s = ('/%s[%d]' % (name, i)) + s
          elt = parent
      return f _backtrace(elt, dom):
      '''Return a "backtrace" from the given element to the DOM root,
      in XPath syntax.
      '''
      s = ''
      while elt != dom:
          name, parent = elt.nodeName, elt.parentNode
          if parent is None: break
          matches = [ c for c in _child_elements(parent) 
                          if c.nodeName == name ]
          if len(matches) == 1:
              s = '/' + name + s
          else:
              i = matches.index(elt) + 1
              s = ('/%s[%d]' % (name, i)) + s
          elt = parent
      return s
docs: Return a "backtrace" from the given element to the DOM root,
      in XPath syntax.