Some time ago we published Phylogenetic Tree Collapser (PTC), a simple and flexible tool to collapse phylogenetic trees using taxonomic information. Documentation is available at the GitHub repository (https://github.com/pegi3s/phylogenetic-tree-collapser), including different use cases. A Docker image is also available here (https://hub.docker.com/r/pegi3s/phylogenetic-tree-collapser).
We have recently published a paper at Journal of Integrative Bioinformatics (https://doi.org/10.1515/jib-2023-0051) describing the tool and demonstrating its utility by addressing the evolution of the ascorbic acid synthesis pathway in insects.