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