iCal recurring events with single edits

I’m trying to write a script that gets all events within certain time parameters. I thought it would just be something like “get all events whose ((start date is greater than x) and (end date is less than y))”

That works fine except for recurring events. Ok, so I added lots of logic to find the recurring events: go through all the events, check the recurrence, see if it lands in the right time frame. That works fine, unless I modify a single event within a recurring series. Then I get both the single modified event and the recurring one.

Any way to test for the duplication?