def _merge_reserved_keys(key, existing_event, new_event):
    """
    A helper function that merges the reserved keys or raises an exception
    when merge not possible
    :param key: The key to be merged
    :param existing_event: The event that's already in the database
    :param new_event: the new event to be merged
    :return: the dictionary with new attributes to merge with
             the existing event
    """
    if key == 'start_time':
        if new_event.start_time is not None:
            existing_event.start_time = min(new_event.start_time,
                existing_event.start_time)
    elif key == 'end_time':
        if new_event.end_time is not None:
            existing_event.end_time = max(new_event.end_time,
                existing_event.end_time)
    elif key == 'description':
        str1 = existing_event.description.strip()
        str2 = new_event.description.strip()
        if str2 and str2 not in str1:
            existing_event.description = str1 + '\n' + str2
    elif key == 'detail_urls':
        for k in new_event.detail_urls:
            if new_event.detail_urls.get(k) is not None:
                existing_event.detail_urls[k] = new_event.detail_urls[k]
    elif getattr(existing_event, key) != getattr(new_event, key):
        raise ValueError(
            'Merge not possible:reserved keys have clashing values.')
