'Given the output of topology.serialize(), deserialize each entity, and:
- insert a new Entry if it didn\'t already exist here, or
- update a pre-existing entry if it already existed'

def deserializeAndMerge(self, id2entity):

    for entity_id in id2entity.keys():
        pickled_entity = id2entity[entity_id].encode('ascii', 'ignore')
        entity = pickle.loads(pickled_entity)
        entity.id = entity_id.encode('ascii', 'ignore')
        try:
            entity.id = int(entity.id)
        except ValueError:
            pass
        existing_entity = self.getEntityByID(entity.id)
        if existing_entity:
            self.log.debug(('New    metadata    for    %s:    %s    ' % (str(existing_entity), str(entity))))
        else:
            self.addEntity(entity)
