Select grease pencil segments with Python

I have drawn 2 intersecting lines with GPencil, if I switch to segment mode that means I can select 4 “segments” . I want to do this with Python, so i can then compare the size of the segments per stroke and delete everything but the longest. Effectively deleting all the useless intersected bits. I’m developing an addon called quickDraw and this would help me out a lot.

I’m stuck at the first part, I cannot automatically select segments. I tried switching to the segment mode before selecting the point to no avail. What can be done?

gpl = gpo.layers[0]
gpf = gpl.frames[0]
gps = gpf.strokes[-1]

bpy.context.scene.tool_settings.gpencil_selectmode_edit = 'SEGMENT'