def merge_tasks(tasks):
	result_tasks = []
	task_mapping = {}
	for task in tasks:
		assert type(task) == dict, repr(type)
		id = task['id']
		assert 'index' not in task
		if id in task_mapping:
			if 'files' in task and 'files' in task_mapping[id]:
				task_mapping[id]['files'] = merge_files(task_mapping[id]['files'], task['files'])
		else:
			if 'files' in task:
				t = dict(task)
				result_tasks.append(t)
				task_mapping[id] = t
			else:
				result_tasks.append(task)
				task_mapping[id] = task
	return result_tasks
dataset/ETHPy150Open iambus/xunlei-lixian/lixian_query.py/merge_tasks/original