if (graph.nodes().contains(currentNode)) { for (N next : graph.successors(currentNode)) { visitNewNode(currentNode, next, distance, newList);
if (graph.nodes().contains(currentNode)) { for (N next : graph.successors(currentNode)) { visitNewNode(currentNode, next, distance, newList);