def METHOD_NAME(p):
    for task_id, sp in p.workflow._get_outermost_workflow().subprocesses.items():
        if p in sp.get_tasks(workflow=sp):
            return p.workflow.get_task_from_id(task_id)