'Compare an XML object against an XML mask.
:param source: The :class:`~xml.etree.ElementTree.Element` XML object
to compare against the mask.
:param mask: The :class:`~xml.etree.ElementTree.Element` XML object
serving as the mask.
:param use_ns: Indicates if namespaces should be respected during
the comparison.
:default_ns: The default namespace to apply to elements that
do not have a specified namespace.
Defaults to ``"__no_ns__"``.'

def _mask_cmp(self, source, mask, use_ns=False, default_ns='__no_ns__'):

    if (source is None):
        return False
    if (not hasattr(mask, 'attrib')):
        try:
            mask = ET.fromstring(mask)
        except ExpatError:
            log.warning('Expat    error:    %s\nIn    parsing:    %s', '', mask)
    mask_ns_tag = ('{%s}%s' % (self.default_ns, mask.tag))
    if (source.tag not in [mask.tag, mask_ns_tag]):
        return False
    if (mask.text and source.text and (source.text.strip() != mask.text.strip())):
        return False
    for (name, value) in mask.attrib.items():
        if (source.attrib.get(name, '__None__') != value):
            return False
    matched_elements = {}
    for subelement in mask:
        matched = False
        for other in source.findall(subelement.tag):
            matched_elements[other] = False
            if self._mask_cmp(other, subelement, use_ns):
                if (not matched_elements.get(other, False)):
                    matched_elements[other] = True
                    matched = True
        if (not matched):
            return False
    return True
