Revert "fix balanced tree-- remove dead code"

This reverts commit b21f84de3226f69d3e19492b538f6a4385a7595a.