 
                 let rightChildIndex = 2 * index + 2
                 if rightChildIndex < self.leafCount {
-                    switch self.newTree[rightChildIndex] {
+                    switch self.tree[rightChildIndex] {
                     case .leaf(let foundRightSymbol):
                         if foundRightSymbol == symbol {
                             index = rightChildIndex


                        let rightChildIndex = 2 * treeIndex + 2
                        if rightChildIndex < self.leafCount {
                            switch self.newTree[rightChildIndex] {
                            case .leaf(let rightSymbol):
                                replacementArray.append(rightSymbol)
                            case .branch(let rightArray):

            let bit = pointerData.bit()
            index = bit == 0 ? 2 * index + 1 : 2 * index + 2
            guard index < self.leafCount else { return -1 }
            switch self.tree[index] {
            case .leaf(let symbol):
                if symbol > -1 {
                    return symbol
