rebuild perfect BST from degenerated BST

featuring http://www.geekviewpoint.com/java/bst/dsw_algorithm