def prepare_return(x):
    '''
    Converts the etree to dict
    '''
    ret = {}
    for a in list(x):
        if a.tag not in ret:
            ret[a.tag] = []
        ret[a.tag].append(prepare_return(a))
    for a in x.attrib:
        ret[a] = x.attrib[a]
    return ret
def prepare_return ( x ) : ret = { } for a in list ( x ) : if a . tag not in ret : ret [ a . tag ] = [ ] ret [ a . tag ] . append ( prepare_return ( a ) ) for a in x . attrib : ret [ a ] = x . attrib [ a ] return ret
Converts the etree to dict