 
 #
 class Mutator extends Iterator
-  # For the current leaf page, give the mutator permission to peek at the right
-  # sibling leaf page if an insert determines that a records key is greater than
-  # the largest record in the current page. The record may belong in a right
-  # sibling page. Peeking at the next page is the only way to resolve the
-  # ambiguity, but loading a leaf has a cost, so we 
-  #
-  # If the insert index of the record is after the last record, but we do not
-  # have permission to peek at the right sibling leaf page to determine if it is
-  # less than the first element of the right sibling, the insert location is
-  # ambiguous and `insert` returns `null`.
-
-  # 
-  peek: ->
-    peeking = @_peek is @count
-    @_peek = @count
-    peeking
-
   # Insert the object into the leaf. Returns the index where the object was
   # inserted in the current leaf page if successful. Returns the bitwise
   # compliment of the location of a record with same key, if a record with the
   # same key already exists in the current leaf page.
-  #
-  # If the insert index of the record is after the last record, but we do not
-  # have permission to peek at the right sibling leaf page to determine if it is
-  # less than the first element of the right sibling, the insert location is
-  # ambiguous and `insert` returns `null`.
   #
   # If the insert index of the record is after the last record, and upon peeking
   # at the first record of the right sibling leaf page we determine that the


    # If we are at the first leaf page and the key is the search key that got us
    # here, then this is, without a doubt, the correct leaf page for the record.
    unambiguous = @count is 1 and @key and @_io.comparator(@key, key) is 0

    if unambiguous
      [ index, found ] = [ @index, @found ]
    else
      index = @_io.find @_page, key, @_page.deleted, _
      unless found = (index >= 0)
        index = ~index
      unambiguous = index <= page.count

    if found
      # TODO Special case: adding a first second copy of a record that has been
      # deleted, but still exists. We put the new record after the first record
      # and it exists as a special kind of duplicate.
      # TODO Think harder about this. It seems like it would work.
      # TODO No, we're not including the `0` in the range.
      index = ~index

    # On every leaf page except the first leave page, the least record is the
    # key, and inserted records are always greater than the key. We assert this
    # here. Do not catch this exception, debug your code.
    if index is 0 and @_page.address isnt -1
      throw new Error "lesser key"

    # TODO Should not be an else.
    else if index >= 0
      if not unambiguous and @_peek is @count
        # The lock must held because the balancer can swoop in and prune the
        # ghost first records and thereby change the key. It could not delete
        # the page nor merge the page, but it can prune dead first records.

        #
        unless unambiguous = page.next is -1
          @_next or= @_io.lock @_page.right, @_exclusive, true, _
          unambiguous = @_io.compare(key, @_io.key(@_next, 0, _)) < 0

      if unambiguous
        # Cache the current count.
        @_io.balancer.unbalanced(@_page)

        # Since we need to fsync anyway, we open the file and and close the file
        # when we append a JSON object to it. Because no file handles are kept
        # open, the b&#x2011;tree object can left to garbage collection.
        filename = @_io.filename @_page.address
        fd = fs.open filename, "a", 0644, _
        position = @_io.writeInsert fd, @_page, index, record, _
        fs.close fd, _

        @_page.positions.splice index, 0, position
        # TODO Why am I not caching the record?
        @_page.count++
        @length = @_page.positions.length
      else
        index = 0
    index

  delete: (index, _) ->
    if not (@_page.deleted <= index < @_page.count)

  # size and total size when we delete a record. We can't recalculate because
  # we're not strict about ownership. The application programmer may decide to
  # alter the object we returned.
  cacheRecord: (page, position, record, key) ->
    key ?= @extractor record

    size = 0
    size += JSON.stringify(record).length
