MC: Pre-process to avoid stripping too many nodes

Remove segments whose endpoints have degree two or more.
MC: Sort segments by length before pruning

To make sure that the output is deterministic
(and that long segments are removed before short segments)