improve balanced binary tree, O(n)