changed the way to prune a tree given an array of leaf names