changed python script to prune filtered groups