@classmethod
def dictify_entity(cls, entity):
    """Turn XML entity into a dictionary"""
    output = entity.attrib
    relations = {}
    if 'type' in output:
        output['_type'] = output['type']
        del output['type']
    for prop in entity:
        if prop.tag == 'entity':
            ent = cls.dictify_entity(prop)
            if prop.attrib.get('rel') == ent.get('_type'):
                relations[prop.attrib.get('rel')] = ent
            else:
                collection = cls.get_collection_name(prop, ent)
                relations.setdefault(collection, []).append(ent)
        else:
            output[prop.attrib['name']] = prop.attrib['value']
    if relations:
        output['relations'] = relations
    return output
