anchor.diff:      % only add the entry if it doesn't exist yet or if it is a sticky node. If its a
       % stickynode, RM told us about a new neighbour -> if the neighbour was already added
       % as a normal node, convert it to a sticky node now.
  -    case gb_trees:lookup(node:id(Entry), get_rt_tree(RT)) =:= none orelse Type =:= sticky of
  +    case gb_trees:lookup(node:id(Entry), get_rt_tree(RT)) =:= none of
           true ->
               % change the type to 'sticky' if the node is between the neighbors of the source
               % node
  
positive.code:             end,
  
              Ns = {NewPred, NewNode, NewSucc} = create_entry(Entry, AdaptedType, RT),
              % if the nodes are all the same, we entered the first node and thus only enter
              % a single node to the tree
              Nodes = case Ns of
                  {NewNode, NewNode, NewSucc} ->
                      gb_trees:enter(entry_nodeid(NewSucc), NewSucc, get_rt_tree(RT));
                      _Else ->
                          gb_trees:enter(entry_nodeid(NewSucc), NewSucc,
                              gb_trees:enter(entry_nodeid(NewNode), NewNode,
                                  gb_trees:enter(entry_nodeid(NewPred), NewPred, get_rt_tree(RT))
                              )
                          )
                  end,
              rt_set_nodes(RT, Nodes);
          false -> RT
      end
      .
  
  
negative.code:             {NewEntry, NewEntry, NewEntry}
              ;
          nil -> % largest finger
              {_PredId, Pred} = gb_trees:largest(Tree),
              get_adjacent_fingers_from(Pred, Node, Type, RT)
              ;
          {value, _PredId, Pred} ->
              get_adjacent_fingers_from(Pred, Node, Type, RT)
      end
      .
  
  % Get the tuple of adjacent finger ids with Node being in the middle:
  % {Predecessor, Node, Successor}
  -spec get_adjacent_fingers_from(Pred::rt_entry(), Node::node:node_type(),
      Type::entry_type(), RT::rt()) -> {rt_entry(), rt_entry(), rt_entry()}.
  get_adjacent_fingers_from(Pred, Node, Type, RT) ->
      PredId = entry_nodeid(Pred),
      Succ = successor_node(RT, Pred),
      SuccId = entry_nodeid(Succ),
      NodeId = node:id(Node),
      NewEntry = #rt_entry{
          node=Node,
          type=Type,
          adjacent_fingers={PredId, SuccId}
      },
      case PredId =:= SuccId of
          false ->
              {set_adjacent_succ(Pred, NodeId),
                  NewEntry,
                  set_adjacent_pred(Succ, NodeId)
              };
          true ->
              AdjacentNode = set_adjacent_fingers(Pred, NodeId, NodeId),
              {AdjacentNode, NewEntry, AdjacentNode}
      end
      .
  
  