Add a tool to dump the search tree in a database too

This is just for debugging (and so I can write tests for similar functionality in C)