lib/RoseTree.js
function flatten(tree) {
  if (!(tree.root instanceof RoseTree)) {
    throw new TypeError("Can't call flatten when elements aren't trees");
  }

  return new RoseTree(
    tree.root.root,
    function() {
      var innerChildren = tree.root.children();
      var outerChildren = tree.children().map(flatten);
      return outerChildren.concat(innerChildren);
    }
  );
}
function flatten(tree) {
  if (!(tree.root instanceof RoseTree)) {
    throw new TypeError("Can't call flatten when elements aren't trees");
  }

  return new RoseTree(
    tree.root.root,
    function() {
      var innerChildren = tree.root.children();
      var outerChildren = tree.children().map(flatten);
      return outerChildren.concat(innerChildren);
    }
  );
}
"Flatten" a tree one level. (Monadic join.) RoseTree (RoseTree a) -> RoseTree a