Update ud_tree.h

Need to change the pointer of temp before deleting it, so it doesn't delete the pointers that are used by the tree.