Fixed bug in prune function

It didn't return the self object