private void RecompositeTree(IReadOnlyDictionary <int, List <HuffmanTreeComponent> > tree)
        {
            List <HuffmanTreeComponent> nodesOfCurrentLevel;

            for (int i = tree.Count - 1; i > 0; i--)
            {
                nodesOfCurrentLevel = tree[i];
                List <HuffmanTreeComponent> nodesOfPreviousLevel = tree[i - 1];
                int finishedNodes = 0;
                for (int j = nodesOfCurrentLevel.Count - 1; j > 0; j = j - 2)
                {
                    HuffmanTreeComponent lastUnusedNode =
                        nodesOfPreviousLevel[nodesOfPreviousLevel.Count - finishedNodes++ - 1];
                    lastUnusedNode.SetLeft(nodesOfCurrentLevel[j - 1]);
                    lastUnusedNode.SetRight(nodesOfCurrentLevel[j]);
                }
            }
        }
        public void ReplaceMostRight()
        {
            if (_fullBitEliminated)
            {
                return;
            }
            HuffmanTreeComponent currentNode  = _root;
            HuffmanTreeComponent previousNode = _root;

            while (currentNode.GetRight() != null)
            {
                previousNode = currentNode;
                currentNode  = currentNode.GetRight();
            }

            previousNode.SetRight(new HuffmanTreeNode(currentNode, new HuffmanTreeNullLeaf()));
            _symbols.Add(new HuffmanTreeNullLeaf());
            _fullBitEliminated = true;
        }