Fix crash in removeOverlappingNotes function (midi import)

Interesting that this logical bug was revealed on MacOS only.