'Recursively fix greek letters in passed in xml.'

def fix_greek_in_mathml(self, xml):

    def gettag(expr):
        return re.sub('{http://[^}]+}', '', expr.tag)
    for k in xml:
        tag = gettag(k)
        if ((tag == 'mi') or (tag == 'ci')):
            usym = unicode(k.text)
            try:
                udata = unicodedata.name(usym)
            except Exception:
                udata = None
            if udata:
                if ('GREEK' in udata):
                    usym = udata.split('    ')[(-1)]
                    if ('SMALL' in udata):
                        usym = usym.lower()
            k.text = usym
        self.fix_greek_in_mathml(k)
    return xml
