Fixing up construction of tree and adding search nodes.