'Checks whether event is in the latest resolved state in context.
If so, returns the version of the event in context.
Otherwise, returns None.'

@defer.inlineCallbacks
def deduplicate_state_event(self, event, context):

    prev_event_id = context.prev_state_ids.get((event.type, event.state_key))
    prev_event = (yield self.store.get_event(prev_event_id, allow_none=True))
    if (not prev_event):
        return
    if (prev_event and (event.user_id == prev_event.user_id)):
        prev_content = encode_canonical_json(prev_event.content)
        next_content = encode_canonical_json(event.content)
        if (prev_content == next_content):
            defer.returnValue(prev_event)
    return
