Basic breadth-first search