def workflows_to_jobs(workflows):
    workflows = sorted(workflows, key=lambda w: w['startTimestamp'])
    workflows = [defaultdict(list, w) for w in workflows]
    jobs = []

    def insert(workflow, roots):
        if workflow not in 'parent':
            jobs.append(workflow)
            return

        parent = [w for w in roots if w['execution']['runId'] == workflow['parent']['runId']]
        if parent:
            parent[0]['children'].append(workflow)
            return True
        else:
            for root in roots:
                if insert(workflow, root['children']):
                    return True
        return False

    for w in workflows:
        insert(w, jobs)
    return jobs
dataset/ETHPy150Open KKBOX/mass/mass/monitor/swf.py/workflows_to_jobs/swapped operands of `not in`