code: def template_to_dict(tree, debug=0, find=False):
      
  
      # you can compare (most) raw Infobox wikitext like this:
      # https://en.wikipedia.org/wiki/TITLE?action=raw&section=0
  
      obj = defaultdict(str)
      errors = []
      for item in tree:
          try:
              name = item.findtext('name').strip()
  
              if debug:
                  template_to_dict_debug(name, item, debug)
  
              find_val = template_to_dict_find(item, debug)  # DEPRECATED
              iter_val = template_to_dict_iter(item, debug)
  
              value = iter_val
              if find:
                  value = find_val
  
              if name and value:
                  obj[name] = value.strip()
  
          except AttributeError:
  
              if isinstance(item, lxml.etree.ElementBase):
                  name = item.tag.strip()
                  text = item.text.strip()
                  if item.tag == 'title':
                      obj['infobox'] = text
                  else:
                      obj[name] = text
  
          except:
              errors.append(lxml.etree.tostring(item))
  
      if errors:
          obj['errors'] = errors
  
      return dict(obj)
docs: returns wikitext template as dict
  
      debug = 1
          prints minimal debug info to stdout
      debug > 1
          compares _iter() versus _find() results
      find = True
          sets values from _find() algorithm (default _iter())