My original code was wrong. When accidental was encountered, it kept it in the tree with bar/moment. The problem was that if the chord happens at that moment, all the notes would get that same accidental. So the solution is to accumulate pitch-accidental pairs for every time accidental occurs.
My original code was wrong. When accidental was encountered, it kept it in the tree with bar/moment. The problem was that if the chord happens at that moment, all the notes would get that same accidental. So the solution is to accumulate pitch-accidental pairs for every time accidental occurs.