private static void populateChildren(final Map<String, Node> spansById) {
    spansById.forEach((spanId, node) -> {
      final SpanData spanData = node.spanData;
      final String parentSpanId = spanData.getParentSpanId();
      if (Objects.equals(parentSpanId, SpanId.getInvalid())) {
        return;
      }
      final Node parentNode = spansById.get(parentSpanId);
      if (parentNode == null) {
        logger.warn("Span {} has parent {} that is not found in index, {}", spanId, parentSpanId,
          spanData);
        return;
      }
      parentNode.children.put(spanId, node);
    });
  }
A Rudimentary tool for visualizing a hierarchy of spans. Given a collection of spans, indexes
them from parents to children and prints them out one per line, indented.
hbase-client/src/test/java/org/apache/hadoop/hbase/client/trace/StringTraceRenderer.java