I need to pick all segments of a line (they are separate features) that go between the end of the line (the last segment, in blue below) and a point that is along the line, but which I need to define with the rule of being the 3rd closest to the end of the line. I tried to illustrate in the figure below. I managed to find the end of the line (the last segment in blue). Between the blue segment and the points A (red) and B (dark blue) there are 6 segments (separation between them are marked in black). How can I find point A and B and have the IDs of the 6 segments between the last one and the point B? Hope this is clear enough and thanks in advance.