added functions to prune trees