Adding breadth-first search algorithm