code: function sortNodesByDepth (graph) {
        // Build the map of nodes to their levels
        let nodesSortedByDepth = [];
        let index;
        for (index in graph.nodes) {
          if ({}.hasOwnProperty.call(graph.nodes, index)) {
            const node = graph.nodes[index];
            nodesSortedByDepth[node.rank] = nodesSortedByDepth[node.rank] || [];
            nodesSortedByDepth[node.rank].push(node);
          }
        }
  
        // Remove empty ranks (and normalize to base 0)
        nodesSortedByDepth = nodesSortedByDepth.reduce((a, n) => { a.push(n); return a; }, []);
  
        const maxNodesPerDepth = 30;
        for (let i = 0; i < nodesSortedByDepth.length; i++) {
          const nodesInDepth = nodesSortedByDepth[i];
          if (nodesInDepth.length > maxNodesPerDepth) {
            const nodesToKeep = Math.min((nodesInDepth.length / 2) - 1, maxNodesPerDepth);
            const newNodeDepth = nodesInDepth.splice(nodesToKeep);
            nodesSortedByDepth.splice(i + 1, 0, newNodeDepth);
          }
        }
  
        return nodesSortedByDepth;
      }
docs: TODO: Make layout deterministic