anchor.diff:      {ok, ResultPos1} = seedtree_write(Fd, Seedtree2, TargetTreeHeight),
       ?debugVal(ResultPos1),
       {ok, Lookup1} = vtree:lookup(Fd, ResultPos1, {0,0,1001,1001}),
  -    ?assertEqual(45, length(Lookup1)),
  -
  -
  -ok.
  +    ?assertEqual(105, length(Lookup1)),
  +
  +    % Test 2.2: input tree is too high (2 levels)
  +    Nodes2 = lists:foldl(fun(I, Acc) ->
  +        {NodeId, {NodeMbr, NodeMeta, NodeData}} =
  +            vtree_test:random_node({I,27+I*329,45}),
  +        Node = {NodeMbr, NodeMeta, {[NodeId, <<"bulk">>], NodeData}},
  +        [Node|Acc]
  +    end, [], lists:seq(1,300)),
  +
  +    Seedtree2_2 = seedtree_insert_list(Seedtree1, Nodes2),
  +    {ok, ResultPos2_1} = seedtree_write(Fd, Seedtree2_2, TargetTreeHeight),
  +    ?debugVal(ResultPos2_1),
  +    {ok, Lookup2_1} = vtree:lookup(Fd, ResultPos2_1, {0,0,1001,1001}),
  +    ?assertEqual(325, length(Lookup2_1)),
  +
  +    % Test 2.3: input tree is too high (1 level) and procudes split
  +    % (seedtree height=1)
  +    TargetTreeNodeNum3 = 64,
  +    TargetTreeHeight3 = log_n_ceil(?MAX_FILLED, TargetTreeNodeNum3),
  +    {Nodes3, Fd3, RootPos3} = create_random_nodes_and_packed_tree(
  +        50, TargetTreeNodeNum3, ?MAX_FILLED),
  +
  +    Seedtree3_1 = seedtree_init(Fd3, RootPos3, 1),
  +    ?debugVal(Seedtree3_1),
  +    Seedtree3_2 = seedtree_insert_list(Seedtree3_1, Nodes3),
  +    {ok, ResultPos3} = seedtree_write(Fd3, Seedtree3_2, TargetTreeHeight3),
  +    ?debugVal(ResultPos3),
  +    {ok, Lookup3} = vtree:lookup(Fd3, ResultPos3, {0,0,1001,1001}),
  +    ?assertEqual(114, length(Lookup3)),
  +
  +    % Test 2.4: input tree is too high (1 level) and produces multiple
  +    % splits (recusively) (seedtree height=2)
  +    % XXX vmx: not really sure if there's more than one split
  +    TargetTreeNodeNum4 = 196,
  +    TargetTreeHeight4 = log_n_ceil(4, TargetTreeNodeNum4),
  +    ?debugVal(TargetTreeHeight4),
  +    {Nodes4, Fd4, RootPos4} = create_random_nodes_and_packed_tree(
  +        50, TargetTreeNodeNum4, 4),
  +    Seedtree4_1 = seedtree_init(Fd4, RootPos4, 2),
  +    ?debugVal(Seedtree4_1),
  +    Seedtree4_2 = seedtree_insert_list(Seedtree4_1, Nodes4),
  +    {ok, ResultPos4} = seedtree_write(Fd4, Seedtree4_2, TargetTreeHeight4),
  +    ?debugVal(ResultPos4),
  +    {ok, Lookup4} = vtree:lookup(Fd4, ResultPos4, {0,0,1001,1001}),
  +    ?assertEqual(246, length(Lookup4)),
  +
  +    % Test 2.5: input tree is too hight (2 level) and produces multiple
  +    % splits (recusively) (seedtree height=2)
  +    % XXX vmx: not really sure if there's more than one split
  +    TargetTreeNodeNum5 = 196,
  +    TargetTreeHeight5 = log_n_ceil(4, TargetTreeNodeNum5),
  +    ?debugVal(TargetTreeHeight5),
  +    {Nodes5, Fd5, RootPos5} = create_random_nodes_and_packed_tree(
  +        100, TargetTreeNodeNum5, 4),
  +    Seedtree5_1 = seedtree_init(Fd5, RootPos5, 2),
  +    ?debugVal(Seedtree5_1),
  +    Seedtree5_2 = seedtree_insert_list(Seedtree5_1, Nodes5),
  +    {ok, ResultPos5} = seedtree_write(Fd5, Seedtree5_2, TargetTreeHeight5),
  +    ?debugVal(ResultPos5),
  +    {ok, Lookup5} = vtree:lookup(Fd5, ResultPos5, {0,0,1001,1001}),
  +    ?assertEqual(296, length(Lookup5)).
   
   
   % @doc Loads nodes from file
  
positive.code:     {ok, Lookup1} = vtree:lookup(Fd, ResultPos1, {0,0,1001,1001}),
      ?assertEqual(45, length(Lookup1)),
  
      % Test 1.2: input tree produces splits (seedtree height=2)
      TargetTreeNodeNum2 = 64,
      TargetTreeHeight2 = log_n_ceil(?MAX_FILLED, TargetTreeNodeNum2),
      {Nodes2, Fd2, RootPos2} = create_random_nodes_and_packed_tree(
  
negative.code:     ?assertEqual(1051, length(Lookup5)).
  
  
  seedtree_write_case2_test() ->
      % Test "Case 2: input R-tree is not shorter than the level of the
      % target node" (chapter 6.2)
      % Test 2.1: input tree is too high (1 level)
      TargetTreeNodeNum = 25,
      % NOTE vmx: wonder why this tree is not really dense
      {ok, {Fd, {RootPos, TargetTreeHeight}}} = vtree_test:build_random_tree(
              "/tmp/seedtree_write.bin", TargetTreeNodeNum),
      ?debugVal(TargetTreeHeight),
      ?debugVal(RootPos),
      Nodes1 = lists:foldl(fun(I, Acc) ->
          {NodeId, {NodeMbr, NodeMeta, NodeData}} =
              vtree_test:random_node({I,27+I*329,45}),
          Node = {NodeMbr, NodeMeta, {[NodeId, <<"bulk">>], NodeData}},
          [Node|Acc]
      end, [], lists:seq(1,80)),
  
      Seedtree1 = seedtree_init(Fd, RootPos, 1),
      ?debugVal(Seedtree1),
  