Adding test and implementation for pathExists with BFS