Modified to use generics in the binary trees.