Returns {name: Command}

def _load_commands(root):
    """Returns {name: Command}"""
    def proto_text(t):
        if t.tag == 'name':
            return '{name}'
        elif t.tag == 'ptype':
            return '{type}'
        out = []
        if t.text:
            out.append(_escape_tpl_str(t.text))
        for x in t:
            out.append(proto_text(x))
            if x.tail:
                out.append(_escape_tpl_str(x.tail))
        return ''.join(out)
    out = collections.OrderedDict()
    for elem in root.findall('commands/command'):
        type_elem = elem.find('proto/ptype')
        name = elem.get('name') or elem.find('proto/name').text
        type = type_elem.text if type_elem is not None else None
        proto_template = proto_text(elem.find('proto'))
        params = [_load_param(x) for x in elem.findall('param')]
        comment = elem.get('comment')
        out[name] = Command(name, type, proto_template, params, comment)
    return out