I am crunching my head already for quite a time regarding a strange behavior of my js script. When I output the value d.parent.x to the console and it shows a different value, than when I print the d.parent to the console and browse for the value through the console.
In the screenshot you see that the object itself has a value x of 525.5, whereas the output of d.parent.x gives me 148.
I m not sure whether this is a js behavior or a behavior of the used D3.js.
I created a jsfiddle for it (source, result). When opening the console in Chrome or Safari you can see the output as in the screenshot.

This is a known issue with console.log – it’s referenced based and will basically end up caching results in some instances when logging objects.
To get around it you can usually do
console.log(JSON.stringify(d.parent))but this doesn’t work in your case due to cyclic references. I just set a breakpoint in your script and looked atd.parentandd.parent.x.They do indeed result in the same value which is the value that
console.log(d.parent.x)shows in your original code.