Outdent children


#1

Can someone please help me with a Automation script to: Outdent the current grandChildren, and delete their parent? Basically I am trying to eliminate the top of the hierarchy, and promote the grandChildren to be the new top level. This is what I am trying right now:

nodes = document.editors[0].rootNode.children
nodes.forEach(function(node){
node.outdentNodes(node.children)
})

And how is it not as simple as:
child.level = child.level - 1;

If I can do that, then I presume I can kill the original parents by simply:
nodes.forEach(function(node){
node.remove()
})