Added functions for tree manipulation, but it seems destroyTree() doesn't work properly yet