Returns {name: Type}

def _load_types(root):
    """Returns {name: Type}"""
    def text(t):
        if t.tag == 'name':
            return '{name}'
        elif t.tag == 'apientry':
            return '{apientry}'
        out = []
        if t.text:
            out.append(_escape_tpl_str(t.text))
        for x in t:
            out.append(text(x))
            if x.tail:
                out.append(_escape_tpl_str(x.tail))
        return ''.join(out)
    out_dict = collections.OrderedDict()
    for elem in root.findall('types/type'):
        name = elem.get('name') or elem.find('name').text
        template = text(elem)
        api = elem.get('api')
        if 'requires' in elem.attrib:
            required_types = set((elem.attrib['requires'],))
        else:
            required_types = set()
        comment = elem.get('comment')
        if api:
            k = (name, api)
        else:
            k = (name, None)
        out_dict[k] = Type(name, template, required_types, api, comment)
    return out_dict