start of tree processing functions