public string Decode(string binaryText) { HuffmanNode iterator = root; string decodedText = ""; for (int i = 0; i < binaryText.Length; i++) { if (binaryText[i] == '0') { iterator = iterator.Left; } else { iterator = iterator.Right; } if (iterator.Left == null && iterator.Right == null) { decodedText += iterator.Value; iterator = root; } } return(decodedText); }