serializeNode = function(node) {
  var result = {
    'id': node._id,
    'title': node._title
  }
  if (node._url)
    result['url'] = node._url;
  else
    result['children'] = node._children.map(serializeNode);
  return result;
}
Moves any misplaced child nodes into their expected positions.