pruning the whole branch if necessary