Finish the prune algorithm.