maxTree O(n) done