restructure tree