[Noob] How to get a list of selected keyframes to iterate over

Hi,
I finally, managed to figure out how to set up the select_leftright operator (and how to set up the proper context - the documentation was not clear. Even though now that I finally got it, it is simple but…still). And I got one bit ,of the script I planned, working. But now want to iterate over the selected keyframes and do some stuff to them. Basically, compare their frame number and based on that make them react in the way I wanted.
How to do that?
Also how can I go in to operator functions like .action.select_leftright() to see how they work? Where to find them?

Thanks but, no thanks. I managed to get that data thanks to a member called quollism and his anim-tools: