anchor.diff:              %?debugVal(NewRootNodes),
               %NewRootNodesPos = write_nodes(Fd, NewRootNodes),
               %?debugVal(NewRootNodesPos),
  -            NewRootNode = {MergedMbr, #node{type=leaf}, [TargetPos|PosList]},
  +            % XXX vmx: is using type=inner always valid?
  +            NewRootNode = {MergedMbr, #node{type=inner}, [TargetPos|PosList]},
               {ok, NewOmtPos} = couch_file:append_term(Fd, NewRootNode),
               {NewOmtPos, TargetHeight+1};
           % split the node and create new root node
  
positive.code:          Fd, {ParentMbr, #node{type=inner}, PosList}),
      {ParentMbr, ParentPos}.
  
  
  % @doc inserts a subtree into an vtree at a specific level. Returns the
  % MBR and position in the file of the new root node.
  -spec insert_subtree(Fd::file:io_device(), RootPos::integer(),
          Subtree::{mbr(), integer()}, Level::integer()) ->
          {ok, mbr(), integer()}.
  insert_subtree(Fd, RootPos, Subtree, Level) ->
      insert_subtree(Fd, RootPos, Subtree, Level, 0).
  
  -spec insert_subtree(Fd::file:io_device(), RootPos::integer(),
          Subtree::{mbr(), integer()}, Level::integer(), Depth::integer()) ->
          {ok, integer()}.
  insert_subtree(Fd, RootPos, Subtree, Level, Depth) when Depth==Level ->
      {SubtreeMbr, SubtreePos} = Subtree,
      {ok, Parent} = couch_file:pread_term(Fd, RootPos),
      {ParentMbr, ParentMeta, EntriesPos} = Parent,
      MergedMbr = vtree:merge_mbr(SubtreeMbr, ParentMbr),
  
      ChildrenPos = [SubtreePos|EntriesPos],
      if
      length(ChildrenPos) =< ?MAX_FILLED ->
          NewNode = {MergedMbr, ParentMeta, ChildrenPos},
  
negative.code:     LeafDepths5 = vtreestats:leaf_depths(Fd5, ResultPos5),
      ?assertEqual([4], LeafDepths5).
  
  insert_subtree_test() ->
      {ok, {Fd, {RootPos, TreeHeight}}} = vtree_test:build_random_tree(
              "/tmp/randtree.bin", 20),
  