solve BALANCED-BINARY-TREE problem with 2 recursive functions