check balanced tree two way implement