public void Traverse(List <byte> chars, List <bool> tree, List <HuffCode> huffCodes, List <bool> path) { if (IsBranch) { tree.Add(true); List <bool> leftPath = new List <bool>(path); leftPath.Add(false); List <bool> rightPath = new List <bool>(path); rightPath.Add(true); Left.Traverse(chars, tree, huffCodes, leftPath); Right.Traverse(chars, tree, huffCodes, rightPath); } else { chars.Add(Symbol); tree.Add(false); huffCodes.Add(new HuffCode(Symbol, path)); } }