Fix ref count handling for key SV value stored in node records

We now increment the count every time we assign the SV to a new record and
decrement it whenever we unassign it from a record.

This makes decrementing the counts when the tree goes out of scope simple. We
simply loop over every allocated node and decrement the count for any data
record's key.