def findTypeParent(element, tag):
 p = element
 while True:
  p = p.getparent()
  if (p.tag == tag):
   return p
 return None

def findTypeParent ( element , tag ) : p = element while True : p = p . getparent ( ) if ( p . tag == tag ) : return p return None
finds fist parent of element of the given type .