Fixes issue with delete function failing on certain types of trees