publicstaticlong findBestPath(Path path) {
long max = 0, sum = 0;
if (path.getChildren().size() == 0)
return path.getValue();
else {
for (int i = 0; i < path.getChildren().size(); i++) {
sum = path.getValue() + findBestPath(path.getChildren().get(i));
if (sum > max)
max = sum;
}
return max;
}
}