prune function

Prunes a tree (using leaves' labels)