Dijkstra: Add null checking for startNode and endNode.