anchor.diff:      DisjointMbrAndPos = [{Mbr, Pos} || {Mbr, Pos, _Children} <- Disjoint],
   
       % Get the actual nodes that should be repacked
  -    NodesToRepack = case lists:append(PosToRepack) of
  +    {NodesToRepack, OmtMbrAndPos2} = case lists:append(PosToRepack) of
       PosToRepack2 when is_tuple(hd(PosToRepack2)) ->
           % Reached leaf nodes
  -        PosToRepack2;
  +
  +        % OMT tree nodes are on the same level as those nodes =>
  +        % OMT tree nodes are leaf nodes => load those nodes
  +        %PosToRepack2
  +        [{_, OmtLeafsPos}] = OmtMbrAndPos,
  +        {ok, {_, _, OmtLeafs}} = couch_file:pread_term(Fd, OmtLeafsPos),
  +        %?debugVal(OmtLeafs),
  +        OmtLeafsMbrAndLeaf = [{Mbr, Leaf} || {Mbr, _, _}=Leaf <- OmtLeafs],
  +        %?debugVal(OmtLeafsMbrAndLeaf),
  +        {PosToRepack2, OmtLeafsMbrAndLeaf};
        PosToRepack2 ->
  -        load_nodes(Fd, PosToRepack2)
  +        %load_nodes(Fd, PosToRepack2)
  +        {load_nodes(Fd, PosToRepack2), OmtMbrAndPos}
       end,
       %PosToRepack2 = lists:append(PosToRepack),
       %NodesToRepack = load_nodes(Fd, PosToRepack2),
  
positive.code:     ?debugVal(ResultPos5),
      {ok, Lookup5} = vtree:lookup(Fd5, ResultPos5, {0,0,1001,1001}),
      ?assertEqual(1051, length(Lookup5)).
  
  
  seedtree_write_case2() ->
      % Test "Case 2: input R-tree is not shorter than the level of the
  
negative.code:         io:format("ERROR: Couldn't open file (~s) for tree storage~n",
                    [Filename])
      end,
  
      Nodes1 = lists:foldl(fun(I, Acc) ->
          {NodeId, {NodeMbr, NodeMeta, NodeData}} =
              vtree_test:random_node({I,20+I*250,30}),
          Node = {NodeMbr, NodeMeta, {NodeId, NodeData}},
          [Node|Acc]
      end, [], lists:seq(1,9)),
  
  %    % Test 1: OMT tree with MAX_FILLEd = 2
  %    {Omt1, _OmtHeight1} = omt_load(Nodes1, 2),
  %    {ok, MbrAndPosList} = omt_write_tree(Fd, Omt1),
  %    RootPosList = [Pos || {Mbr, Pos} <- MbrAndPosList],
  %    ?debugVal(RootPosList),
  %
  %    % just test if the number of children match on all levels
  %    ?assertEqual(2, length(RootPosList)),
  %    {ok, L1a} = couch_file:pread_term(Fd, lists:nth(1, RootPosList)),
  %    ?assertEqual(2, length(element(3, L1a))),
  %    {ok, L1b} = couch_file:pread_term(Fd, lists:nth(2, RootPosList)),
  %    ?assertEqual(2, length(element(3, L1b))),
  %    {ok, L2a} = couch_file:pread_term(Fd, lists:nth(1, element(3, L1a))),
  %    ?assertEqual(2, length(element(3, L2a))),
  %    %?assertEqual(3, length(element(3, L2a))),
  %    {ok, L2b} = couch_file:pread_term(Fd, lists:nth(2, element(3, L1a))),
  %    ?assertEqual(1, length(element(3, L2b))),
  %    {ok, L2c} = couch_file:pread_term(Fd, lists:nth(1, element(3, L1b))),
  %    ?assertEqual(1, length(element(3, L2c))),
  %    {ok, L2d} = couch_file:pread_term(Fd, lists:nth(2, element(3, L1b))),
  %    ?assertEqual(1, length(element(3, L2d))),
  %    {ok, L3aNode} = couch_file:pread_term(Fd, lists:nth(1, element(3, L2a))),
  %    {_, _, L3a} = L3aNode,
  %    {ok, L3bNode} = couch_file:pread_term(Fd, lists:nth(2, element(3, L2a))),
  %    {_, _, L3b} = L3bNode,
  %    {ok, L3cNode} = couch_file:pread_term(Fd, lists:nth(1, element(3, L2b))),
  %    {_, _, L3c} = L3cNode,
  %    {ok, L3dNode} = couch_file:pread_term(Fd, lists:nth(1, element(3, L2c))),
  %    {_, _, L3d} = L3dNode,
  %    {ok, L3eNode} = couch_file:pread_term(Fd, lists:nth(1, element(3, L2d))),
  %    {_, _, L3e} = L3eNode,
  %%    {_, _, [L3aNode, L3bNode]} = L2a,
  %%    {_, _, [L3cNode]} = L2b,
  %%    {_, _, [L3dNode]} = L2c,
  %%    {_, _, [L3eNode]} = L2d,
  %?debugVal(L3eNode),
  %    {_, _, L3a} = L3aNode,
  %    {_, _, L3b} = L3bNode,
  %    {_, _, L3c} = L3cNode,
  %    {_, _, L3d} = L3dNode,
  %    {_, _, L3e} = L3eNode,
  %
  %    [L4a, L4b] = L3a,
  %    [L4c] = L3b,
  %    [L4d, L4e] = L3c,
  %    [L4f, L4g] = L3d,
  %    [L4h, L4i] = L3e,
  %
  %    ?assert(is_tuple(L4a)),
  %    ?assert(is_tuple(L4b)),
  %    ?assert(is_tuple(L4c)),
  %    ?assert(is_tuple(L4d)),
  %    ?assert(is_tuple(L4e)),
  %    ?assert(is_tuple(L4f)),
  %    ?assert(is_tuple(L4g)),
  %    ?assert(is_tuple(L4h)),
  %    ?assert(is_tuple(L4i)),
  %
  %
  %    % Test 2: OMT tree with MAX_FILLEd = 4
  %    {Omt2, _OmtHeight2} = omt_load(Nodes1, 4),
  %    {ok, MbrAndPosList2} = omt_write_tree(Fd, Omt2),
  %    RootPosList2 = [Pos || {Mbr, Pos} <- MbrAndPosList2],
  %    ?assertEqual(3, length(RootPosList2)),
  %
  %    %[M1aNode, M1bNode, M1cNode] = RootPosList2,
  %    {ok, M1aNode} = couch_file:pread_term(Fd, lists:nth(1, RootPosList2)),
  %    {_, _, M1a} = M1aNode,
  %    ?assertEqual(3, length(M1a)),
  %    {ok, M1bNode} = couch_file:pread_term(Fd, lists:nth(2, RootPosList2)),
  %    {_, _, M1b} = M1bNode,
  %    ?assertEqual(3, length(M1b)),
  %    {ok, M1cNode} = couch_file:pread_term(Fd, lists:nth(3, RootPosList2)),
  %    {_, _, M1c} = M1cNode,
  %    ?assertEqual(3, length(M1c)),
  %    [M2a, M2b, M2c] = M1a,
  %    [M2d, M2e, M2f] = M1b,
  %    [M2g, M2h, M2i] = M1c,
  %    ?assert(is_tuple(M2a)),
  %    ?assert(is_tuple(M2b)),
  %    ?assert(is_tuple(M2c)),
  %    ?assert(is_tuple(M2d)),
  %    ?assert(is_tuple(M2e)),
  %    ?assert(is_tuple(M2f)),
  %    ?assert(is_tuple(M2g)),
  %    ?assert(is_tuple(M2h)),
  %    ?assert(is_tuple(M2i)),
  
  
      % Test 3: OMT tree with MAX_FILLEd = 4 and only one node
      Node = [{{68,132,678,722},#node{type=leaf},{<<"Node-1">>,<<"Value-1">>}}],
     %Node= [
     %       {{68,132,678,722},#node{type=leaf},{<<"Node-1">>,<<"Value-1">>}},
     %       {{32,145,582,729},#node{type=leaf},{<<"Node-2">>,<<"Value-2">>}}
     %      ],
      
      {Omt3, OmtHeight3} = omt_load(Node, 4),
      ?debugVal(Omt3),
      ?debugVal(OmtHeight3),
      {ok, MbrAndPosList3} = omt_write_tree(Fd, Omt3),
      ?debugVal(MbrAndPosList3),
      RootPosList3 = [Pos || {Mbr, Pos} <- MbrAndPosList3],
      ?debugVal(RootPosList3),
      {ok, Lookup3} = vtree:lookup(Fd, lists:nth(1,RootPosList3), {0,0,1001,1001}),
      ?debugVal(Lookup3),
      
  %    ?assertEqual(3, length(RootPosList2)),
  
  
  %    % Test 4: round-trip: some nodes => OMT tree, write to disk, load from disk
  %?debugVal(RootPosList),
  %    {ok, LeafNodes1} = vtree:lookup(
  %            Fd, lists:nth(1, RootPosList), {0,0,1001,1001}),
  %    {ok, LeafNodes2} = vtree:lookup(
  %            Fd, lists:nth(2, RootPosList), {0,0,1001,1001}),
  %    LeafNodes3 = lists:foldl(fun(LeafNode, Acc) ->
  %        {NodeMbr, NodeId, NodeData} = LeafNode,
  %        Node = {NodeMbr, #node{type=leaf}, {NodeId, NodeData}},
  %        [Node|Acc]
  %    end, [], LeafNodes1 ++ LeafNodes2),
  %    {Omt3, _OmtHeight3} = omt_load(LeafNodes3, 2),
  %   ?assertEqual(Omt1, Omt3).
  ok.
  
  
  omt_sort_nodes_test() ->
  