Yep! This linear-time algorithm described by Buchheim et al. is used by d3.layout.tree:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;d3&#x2F;d3-hierarchy&#x2F;blob&#x2F;master&#x2F;src&#x2F;tree.js" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;d3&#x2F;d3-hierarchy&#x2F;blob&#x2F;master&#x2F;src&#x2F;tree.js</a>