I have a Shapely multiline string that has multiple branches that I want removed. I've attached an image where the red is the main line that I want to keep and the black are to be removed. I can't filter based on individual linestring lengths as some segments that need to be kept are shorter than the branches. I was thinking a Depth-First Search would be appropriate but I'm unsure how to implement it when working with a shapely object. As well as calculate the full length of the main line. Any tips would be appreciated. Continue reading...