Two fixes in sortedChildren appear to partially solve this problem (flipping the order of the x arguments):
base = normalize(Math.atan2(p.y-n.y, p.x-n.x));
angles[i] = normalize(-base + Math.atan2(c.y-n.y,c.x-n.x));
However the problem still occurs after a new root node is selected. Disabling calcAngularBounds using setTheta appears to be a workaround.