single threaded breadth-first search