private static <T> void printNodes(Iterator<? extends T> nodes,
                                     Function<? super T, ? extends Iterator<? extends T>> getter,
                                     int indent,
                                     Set<? super T> visited,
                                     StringBuilder buffer) {
    while (nodes.hasNext()) {
      T node = nodes.next();
      StringUtil.repeatSymbol(buffer, ' ', indent);
      buffer.append(node);
      if (visited.add(node)) {
        buffer.append('\n');
        printNodes(getter.fun(node), getter, indent + 2, visited, buffer);
      }
      else {
        buffer.append(" [...]\n");
      }
    }
  }
private static <T> void printNodes(Iterator<? extends T> nodes,
                                     Function<? super T, ? extends Iterator<? extends T>> getter,
                                     int indent,
                                     Set<? super T> visited,
                                     StringBuilder buffer)