It might be possible to greatly improve the node number calculation algorithm. Some notes:
Either do something similar like generateNodeNumberForSelectedNodeIfNoneExistsYet: Generate "trial" cells and add them to the dictionary only if no other cell existed yet.
Or write a stateful algorithm.
In any case: Write unit tests first.
Optimize drawing of node tree view: For some changes it might not be necessary to redraw the entire tree.
Example: When a new node is added.
Measure before/after performance on a real device.
generateNodeNumberForSelectedNodeIfNoneExistsYet
: Generate "trial" cells and add them to the dictionary only if no other cell existed yet.