Even though a graph database as backend storage would be a great feature for Gramps, in my comment I was more thinking about using network graphs as a research tools.
Even the mongodb backend is a great feature if it was being updated.
But as a research tool, network graphs has an even stronger capacity when it comes to find “hidden” relations, like what the problem in this post describe.
You don’t need the graphical view of the network, even though it is great to visualize most “problems” and the “answers” of a research question.
It is also possible to just use the resulting dataset in a table, or in a multi-table Gramps View.
There is also possible to add graph functionality to sqlite, it will work similar to the node and edge tables in Gephi, Cytoscape or other network graph tools that can show the data in a table view.
I don’t know if it is possible to run these tools in SuperTool or the Python Shell Gramplet, but by using panda and networkx (or any other graph library), this type of problems should be easily resolved by creating a graph dataset and a graph algorithm on that data e.g., a nearest neighbor with 2-3 hop, it would also be possible to build sub-graphs with more even more hop than that if needed, e.g., if you need to traverse through a full place hierarchy.
At the end, the data could be presented both as a visual network graph, and as table views.
But, my comment was just a tip about how it might be done if it was possible to use panda and e.g., networkx via SuperTool or the Python shell gramplet.
Personally, I have stopped using Gramps for any research, it is just a storage of already confirmed data for me. I find the near unlimited possibilities to use plain text markdown notes and tools like Foam for VSC and other extensions for VSC or Obsidian with its large number of plugins a lot easier to use when it comes to research and finding relation across objects/subject in my research. With those tools it is possible to find relations in both structured and unstructured text.
I did not know that you used neo4j and imported from the xml file, so I will, even though I am not a developer, look at that, it really interest me, so thank you for that infortmation