refactor the NewTreeTopology to use nTasks instead maxID

this way, we can use number of task directly, a more natural way of specify the number of tasks.