def METHOD_NAME(wf):
    new_tasks = {}
    for task in wf['tasks'].values():
        if task['task_spec'].endswith('BoundaryEventParent'):
            task['task_spec'] = task['task_spec'].replace('BoundaryEventParent', 'BoundaryEventSplit')
            completed = all([ wf['tasks'][child]['state'] in [64, 256] for child in task['children'] ])
            for child in task['children']:
                child_task = wf['tasks'][child]
                if child_task['state'] < 8:
                    # MAYBE, LIKELY, FUTURE: use parent state
                    state = child_task['state']
                elif child_task['state'] < 64:
                    # WAITING, READY, STARTED (definite): join is FUTURE
                    state = 4
                elif child_task['state'] == 64:
                    # COMPLETED: if the join is not finished, WAITING, otherwise COMPLETED
                    state = 64 if completed else 8
                elif child_task['state'] == 128:
                    # ERROR: we don't know what the original state was, but we can't proceed through the gateway
                    state = 8
                else:
                    # Cancelled tasks don't have children
                    continue
                new_task = {
                    'id': str(uuid4()),
                    'parent': child_task['id'],
                    'children': [],
                    'state': state,
                    'task_spec': task['task_spec'].replace('BoundaryEventSplit', 'BoundaryEventJoin'),
                    'last_state_change': None,
                    'triggered': False,
                    'internal_data': {},
                    'data': {},
                }
                child_task['children'].append(new_task['id'])
                new_tasks[new_task['id']] = new_task
    wf['tasks'].update(new_tasks)
    pass