code: def recursive_parse_xml_to_dict(xml):
      """Recursively parses XML contents to python dict.
  
      We assume that `object` tags are the only ones that can appear
      multiple times at the same level of a tree.
  
      Args:
        xml: xml tree obtained by parsing XML file contents using lxml.etree
  
      Returns:
        Python dictionary holding XML contents.
      """
      if not xml:
          return {xml.tag: xml.text}
      result = {}
      for child in xml:
          child_result = recursive_parse_xml_to_dict(child)
          if child.tag != "object":
              result[child.tag] = child_result[child.tag]
          else:
              if child.tag not in result:
                  result[child.tag] = []
              result[child.tag].append(child_result[child.tag])
      return {xml.tag: result}
  
file_path: DALI/docs/examples/use_cases/tensorflow/efficientdet/dataset/tfrecord_util.py
imports: from six.moves import range
  import tensorflow
label_desc: Use image node_id 7 for calling a global function with example usage: recursive_parse_xml_to_dict(xml) and returns: dict, dict