finished Bacon BFS, untested (no database to test with)