pseudocode for pruning the tree