data = {}
for anid in tree.getroot().getchildren():
    currdict = data[anid.get('name')] = {}
for atype in anid.getchildren():
    currlist = currdict[atype.get('name')] = []
for c in atype.getchildren():
    currlist.append((c.get('val'), c.get('id')))
return data
Разбор XML в хеш-таблицу