forall(AlgorithmState state, DataSpec spec) if spec is a leaf then process(state, spec) return state, spec split state into states split spec into specs if maximum number of threads reached then for all state, spec in states, specs do forall(state, spec) else for all state, spec in states, specs in parallel do forall(state, spec) merge states into result_state merge specs into result_spec return result_state, result_spec