Analyze collection of lines and find the shortest one in each cluster

I have a collection of lines. i want to extract the shortest line segment in each “cluster”/direction. I have tried to experiment using the pipe function, but have not managed to find a good solution. It must be possible to use a function like “trim with brep” and use “inside” parameter?
lines in lines.gh (1.8 KB)

Like this?


lines in lines_re.gh (10.3 KB)