void (int nodeIndex) { DfsUtilKt.walk(nodeIndex, currentNode -> { boolean firstVisit = myLayoutIndex[currentNode] == 0; if (firstVisit) myLayoutIndex[currentNode] = currentLayoutIndex; int childWithoutLayoutIndex = -1; for (int childNodeIndex : getDownNodes(myGraph, currentNode)) { if (myLayoutIndex[childNodeIndex] == 0) { childWithoutLayoutIndex = childNodeIndex; break; } } if (childWithoutLayoutIndex == -1) { if (firstVisit) currentLayoutIndex++; return Dfs.NextNode.NODE_NOT_FOUND; } else { return childWithoutLayoutIndex; } }); }