Test if two interface elements should be considered like the same device

def _nics_equal(nic1, nic2):
    '''
    Test if two interface elements should be considered like the same device
    '''

    def _filter_nic(nic):
        '''
        Filter out elements to ignore when comparing nics
        '''
        return {
            'type': nic.attrib['type'],
            'source': nic.find('source').attrib[nic.attrib['type']] if nic.find('source') is not None else None,
            'mac': nic.find('mac').attrib['address'].lower() if nic.find('mac') is not None else None,
            'model': nic.find('model').attrib['type'] if nic.find('model') is not None else None,
        }
    return _filter_nic(nic1) == _filter_nic(nic2)