'Return a set of all identities in tuple form as so:
(category, type, lang, name)
If a language was specified, only return identities using
that language.
Arguments:
lang   -- Optional, standard xml:lang value.
dedupe -- If True, de-duplicate identities, otherwise
return a list of all identities.'

def get_identities(self, lang=None, dedupe=True):

    if dedupe:
        identities = set()
    else:
        identities = []
    for id_xml in self.findall(('{%s}identity' % self.namespace)):
        xml_lang = id_xml.attrib.get(('{%s}lang' % self.xml_ns), None)
        if ((lang is None) or (xml_lang == lang)):
            id = (id_xml.attrib['category'], id_xml.attrib['type'], id_xml.attrib.get(('{%s}lang' % self.xml_ns), None), id_xml.attrib.get('name', None))
            if dedupe:
                identities.add(id)
            else:
                identities.append(id)
    return identities
