def findElementsWithId(node, elems=None):
 if (elems is None):
  elems = {}
 id = node.getAttribute('id')
 if (id != ''):
  elems[id] = node
 if node.hasChildNodes():
  for child in node.childNodes:
   if (child.nodeType == 1):
    findElementsWithId(child, elems)
 return elems

def findElementsWithId ( node , elems = None ) : if ( elems is None ) : elems = { } id = node . getAttribute ( 'id' ) if ( id != '' ) : elems [ id ] = node if node . hasChildNodes ( ) : for child in node . childNodes : if ( child . nodeType == 1 ) : findElementsWithId ( child , elems ) return elems
returns all elements with id attributes .