Convert d3.layout.tree to stack-based.

Tree layout now implemented using stacks instead of recursive calls to fix stack overflows caused by very deep trees (see #1868).