Test if two graphics devices should be considered the same device

def _graphics_equal(gfx1, gfx2):
    '''
    Test if two graphics devices should be considered the same device
    '''
    def _filter_graphics(gfx):
        '''
        When the domain is running, the graphics element may contain additional properties
        with the default values. This function will strip down the default values.
        '''
        gfx_copy = copy.deepcopy(gfx)

        defaults = [{'node': '.', 'attrib': 'port', 'values': ['5900', '-1']},
                    {'node': '.', 'attrib': 'address', 'values': ['127.0.0.1']},
                    {'node': 'listen', 'attrib': 'address', 'values': ['127.0.0.1']}]

        for default in defaults:
            node = gfx_copy.find(default['node'])
            attrib = default['attrib']
            if node is not None and (attrib not in node.attrib or node.attrib[attrib] in default['values']):
                node.set(attrib, default['values'][0])
        return gfx_copy

    return ElementTree.tostring(_filter_graphics(gfx1)) == ElementTree.tostring(_filter_graphics(gfx2))