   # single branch to the parent, this operation will empty the root into two
   # separate tiers, creating an almost empty root each time it is split.
   _drainRoot: (mutation) ->
+    # Create new left and right inner tiers.
+    left = @_newInnerTier mutation, root.leafChildren
+    right = @_newInnerTier mutation, root.leafChildren
+
+    # Find the partition index and move the branches up to the partition
+    # into the left inner tier. Move the branches at and after the partiion
+    # into the right inner tier.
+    partition = root.lenth / 2
+    fullSize = root.length
+    for i in [0...partition]
+      left.push root[i]
+    for i in [partition...root.length]
+      right.push root[i]
+
+    # Empty the root.
+    root.length = 0
+
+    # The left-most pivot or the right inner tier is null.
+    pivot = right[0].record
+    right[0].record = null
+
+    # Add the branches to the new left and right inner tiers to the now
+    # empty root tier.
+    root.push { pivot: null, left.address }
+    root.push { pivot, right.address }
+
+    # Set the child type of the root tier to inner.
+    root.leafChildren = false
+
+    # Stage the dirty tiers for write.
+    @io.dirty root, left, right
 
   # Determine if the root inner tier should be filled with contents of a two
   # extra remaining inner tier children. When an root inner tier has only one

    throw new Error("Root address is required.") unless @rootAddress = options.rootAddress
    @locks = { shared: {}, exclusive: {} }

  add: (object, callback) ->
    fields = @io.fields object
    @_mutation new Mutation(this, @_shouldDrainRoot)

  generalized: (mutation) ->
    mutation.levels.push new Level(false)
    mutation.parent = @io.root @rootAddress
    mutation.parentLevel = new Level(false)

    @decisions = { root, initial, subsequent, swap, penultimate }

class Level
  constructor: (@exclusive) ->
  lock: (strata, mutation, tier, callback) ->
    @tierId = tier.id
    locks = (strata.locks[@tierId] or= [ [] ])
    if @exclusive
      locks.push [ @lockCallback = [ callback, strata, mutation ] ]
      locks.push []
      if locks.length is 3 and locks[0].length is 0
        callback.call strata
    else
      locks[locks.length - 1].push @lockCallback = [ callback, strata, mutation ]
      if locks.length is 1
        callback.call strata

class module.exports.MemoryIO
  root: (map) -> map
