Bad API for bfs.