I need to create a table from an xml data file given below. For each `mytag`, I need to find all the items available inside `symbol` tag at higher level up in the tree.

For example, When I read 7th line having value `EEEEE` in `symbol` tag, I want to report everything in `symbol` tag in nodes that are high up in the tree. The result would be `AAAAA, BBBBB,CCCCC,DDDDD,EEEEE.

Similarly, while reading line 5 with `CCCCC` as value in `symbol` tag, the expected result would be `AAAAA, BBBBB, CCCCC`.

Code:
  <?xml version="1.0" encoding="UTF-8"?>
    <class-scheme publication-date="2013-12-03" scheme-type="cpc" publication-type="official">
        <mytag   level="5"  key="G06G" ><symbol>AAAAA</symbol>
            <mytag   level="6"  key="G06G1/00" ><symbol>BBBBB</symbol>
                <mytag   level="7"  key="G06G1/00" ><symbol>CCCCC</symbol>
                    <mytag   level="8"  key="G06G1/0005" ><symbol>DDDDD</symbol>
                        <mytag   level="9"  key="G06G1/001" ><symbol>EEEEE</symbol></mytag>
                        <mytag   level="9"  key="G06G1/0015" ><symbol>FFFFF</symbol></mytag>
                        <mytag   level="9"  key="G06G1/0031" ><symbol>G06G1/0031</symbol></mytag>
                        <mytag   level="9"  key="G06G1/0073" ><symbol>G06G1/0073</symbol>
                            <mytag   level="10"  key="G06G1/0078" ><symbol>G06G1/0078</symbol></mytag>
                            <mytag   level="10"  key="G06G1/0084" ><symbol>G06G1/0084</symbol></mytag>
                            <mytag   level="10"  key="G06G1/0089" ><symbol>G06G1/0089</symbol></mytag>
                        </mytag>
                        <mytag   level="9"  key="G06G1/0094" ><symbol>G06G1/0094</symbol></mytag>
                    </mytag>
                </mytag>
                <mytag   level="7"  key="G06G3/00" ><symbol>G06G3/00</symbol>
                    <mytag   level="8"  key="G06G3/02" ><symbol>G06G3/02</symbol></mytag>
                    <mytag   level="8"  key="G06G3/04" ><symbol>G06G3/04</symbol></mytag>
                    <mytag   level="8"  key="G06G3/06" ><symbol>G06G3/06</symbol></mytag>
                </mytag>
            </mytag>
        </mytag>
    </class-scheme>
My code:

Code:
    def process_subtree(c, path):
    #print(ET.tostring(c))
    if c.tag == "mytag":
        mykey = c.get("key")
        mylevel = c.get("level")
        mysymbol  = c.get("symbol")
        narr = [mykey, mylevel, mysymbol]
        narr = [x if x is not None else '' for x in narr]
        print("\t".join(narr))
    else:
        mysymbol = None
    if(mysymbol):
        path.append(mysymbol)
        nodes.append('/'.join(path))
    for c1 in c:
        process_subtree(c1, path)
    if(mysymbol):
        path.pop()
        print(nodes)


    nodes = []
    import xml.etree.ElementTree as ET
    tree = ET.parse("ex.xml")
    root = tree.getroot()
    process_subtree(root, [])