it looks to me like there's a bug when you're removing a node that has
removeNode() calls _deleteNode(), which calls removeChildren()
removeChildren iterates over the child collection, from the 0 index up
to the collection length, removing them one at a time. It looks like
this causes the indexes to change as you're iterating over them, so it
gets halfway through then blows up with a null reference.
Making it loop in reverse order seems to work:
I changed this line:
for (var i=0, len=node.children.length;i<len;++i)
for (var i=node.children.length-1;i>=0;i--)
and it's working for me now..