Why destroy `nodeStack` here?  If you really want to kill it from within this code, you probably want to do `nodeStack.length = 0;`