maxTree O(n) scan method, faster than stack