import json


def parse_event_payload(event):
    """
    Given an event, parse the 'event' field, if found otherwise 'data' field as a JSON string.

    Note that this may simply return the same event unchanged, or return a new copy of the event with the payload
    parsed. It will never modify the event in place.
    """
    payload_key = 'event' if 'event' in event else 'data'
    if payload_key in event and isinstance(event[payload_key], str):
        event = event.copy()
        try:
            event[payload_key] = json.loads(event[payload_key])
        except ValueError:
            pass
    return event