If Musescore was being built today using web technologies like React etc., it would have definitely been built with a tree-like model for the score with each element in the score containing the smaller elements, like Score -> Staff -> Measure -> Note -> Accidental. In the case of Musescore, the code was written manually for QT, with all the drawing and file handling code written manually. So the classes in libmscore follow this tree-like model somewhat informally, but not explicitly. I will be refactoring the code, such that the classes in libmscore follow this model exactly by adding a "children" list to the ScoreElement class. Many operations can then be written as tree traversals. This would prevent a lot of duplication in code, and simplify the code in a lot of places.