This extension of prefix-sum trees to multiple dimensions might apply:
https://arxiv.org/pdf/1311.6093.pdf
Pushkar Mishra (2013). "A New Algorithm for Updating and Querying Sub-arrays of Multidimensional Arrays". arXiv:1311.6093 [cs.DS]. doi:10.13140/RG.2.1.2394.2485
This extension of prefix-sum trees to multiple dimensions might apply: https://arxiv.org/pdf/1311.6093.pdf Pushkar Mishra (2013). "A New Algorithm for Updating and Querying Sub-arrays of Multidimensional Arrays". arXiv:1311.6093 [cs.DS]. doi:10.13140/RG.2.1.2394.2485