No, this seems to work correctly as written. I'm setting node.children in later iterations so setChildNodes actually receives an object with many levels.