public static <Node> void performDfs(
    @NotNull OutboundSemiGraph<Node> graph,
    @NotNull Node root,
    @NotNull Consumer<? super Node> visitor
  ) {
    final Set<Node> visited = new HashSet<>();
    final Deque<Node> stack = new ArrayDeque<>();
    stack.push(root);

    while (!stack.isEmpty()) {
      final Node curr = stack.pop();

      if (!visited.contains(curr)) {
        visitor.accept(curr);
        visited.add(curr);
      }

      graph.getOut(curr).forEachRemaining(next -> {
        if (!visited.contains(next)) {
          stack.push(next);
        }
      });
    }
  }
public static <Node> void performDfs(
    @NotNull OutboundSemiGraph<Node> graph,
    @NotNull Node root,
    @NotNull Consumer<? super Node> visitor
  )