/**
 * Takes an element, removes it and replaces it with it's childs
 *
 * @param {Object} node The node which to replace with it's child nodes
 * @example
 *    <div id="foo">
 *      <span>hello</span>
 *    </div>
 *    <script>
 *      // Remove #foo and replace with it's children
 *      wysihtml.dom.replaceWithChildNodes(document.getElementById("foo"));
 *    </script>
 */
wysihtml.dom.replaceWithChildNodes = function(node) {
  if (!node.parentNode) {
    return;
  }

  while (node.firstChild) {
    node.parentNode.insertBefore(node.firstChild, node);
  }
  node.parentNode.removeChild(node);
};
