Adding O(n) solution for balanced binary tree