I am trying to use a D3 tree layout to create a family tree, and one of the things I noticed is that when I have many child nodes, it will stretch horizontally across the screen. Ideally, I would like to have a more vertical layout for these nodes so that people cannot scroll the screen and can just look down the tree.
Here is what I see now:

Now this may not be so bad, but if I said 20 children, it would cover the whole screen, and this is what I want to avoid.
I saw questions like this one , but that doesnβt help me because I want a specific layout, not just size ... I have large nodes and they start to collide with each other if I try to dynamically resize the tree - shortening tree does not bring me any benefit. I definitely need a different layout for situations where there are more than a certain number of children.
This is what I foresaw / hoped for. Note that the root does not do this format because it has only 4 children. Ideally, I want if a parent had 5 or more children, this would lead to a layout below. If the root had 5 children, this would lead to such a layout, and the layout should simply stretch vertically if users wanted to see the root grandchildren (nodes A, B, C ...). If necessary, I can get a diagram: 
I found a semi-similar question regarding custom layouts for kids , and he said he needed to play around with the actual d3js code. I would like to avoid this, so I hope to find out if this is possible with d3js, as it is now, and if so, how to do it? I do not need a complete answer, but a piece of code proving that this is possible will be very useful.
If necessary, I can download a JSFiddle for people to play with.