This will require some way of tracking the whole order all currently held notes were pressed in. Might be a good candidate for a doubly linked list. (as notes are released, remove them from the list in place; if head of list is removed, re-activate new head of list)
This tracking of order could be useful for note stealing as well
Highest note
If highest note is released, find next highest held note.
Lowest note
If lowest note is released, find next lowest held note.
Possible options: