def find_element(tagid, sel):
 if isinstance(tagid, _Element):
  return tagid
 if isinstance(tagid, dict):
  tagid = tagid.get('tagid')
 elements = sel.xpath(('//*[@data-tagid="%s"]' % tagid))
 if elements:
  return elements[0].root

def find_element ( tagid , sel ) : if isinstance ( tagid , _Element ) : return tagid if isinstance ( tagid , dict ) : tagid = tagid . get ( 'tagid' ) elements = sel . xpath ( ( '//*[@data-tagid="%s"]' % tagid ) ) if elements : return elements [ 0 ] . root
find an element by its tagid .