 
   defp do_fetch(node, key, hash) do
     index = key_mask(hash)
-    case elem(node, index) do
-      [^key | v]   -> {:ok, v}
+
+    case elem(node, index) do
+      [^key | v] -> {:ok, v}
       {^key, v, _} -> {:ok, v}
-      {_, _, n}    -> do_fetch(n, key, key_shift(hash))
-      _            -> :error
+      {_, _, n} -> do_fetch(n, key, key_shift(hash))
+      _ -> :error
     end
   end
 
   defp do_put(node, key, value, hash) do
     index = key_mask(hash)
+
     case elem(node, index) do
       [] ->
         {put_elem(node, index, [key | value]), 1}
+
       [^key | _] ->
         {put_elem(node, index, [key | value]), 0}
+
       [k | v] ->
         n = put_elem(@node_template, key_mask(key_shift(hash)), [key | value])
         {put_elem(node, index, {k, v, n}), 1}
+
       {^key, _, n} ->
         {put_elem(node, index, {key, value, n}), 0}
+
       {k, v, n} ->
         {n, counter} = do_put(n, key, value, key_shift(hash))
         {put_elem(node, index, {k, v, n}), counter}


  defp do_delete(node, key, hash) do
    index = key_mask(hash)
    case elem(node, index) do
      [] ->
        :error
      [^key | value] ->
        {put_elem(node, index, []), value}
      [_ | _] ->
        :error
      {^key, value, n} ->
        {put_elem(node, index, do_compact_node(n)), value}
      {k, v, n} ->
        case do_delete(n, key, key_shift(hash)) do
          {@node_template, value} ->
            {put_elem(node, index, [k | v]), value}
          {n, value} ->
            {put_elem(node, index, {k, v, n}), value}
          :error ->
            :error
        end
    end
  end

  Enum.each 0..(@node_size - 1), fn index ->
    defp do_compact_node(node) when elem(node, unquote(index)) != [] do
      case elem(node, unquote(index)) do
        [k | v] ->

  def reduce(%HashDict{root: root}, acc, fun) do
    do_reduce(root, acc, fun, @node_size, fn
      {:suspend, acc} -> {:suspended, acc, &{:done, elem(&1, 1)}}
      {:halt, acc} -> {:halted, acc}
      {:cont, acc} -> {:done, acc}
    end)
  end

