Fix BFS bug when return null if no path is found