public BitList ToBitList(byte[] data) { var tokens = new Stack <IToken>(); State endState = EndBinaryShift(data.Length); for (IToken token = endState.Tokens; token != null; token = token.PreviousToken) { tokens.Push(token); } var result = new BitList(); while (tokens.Any()) { IToken token = tokens.Pop(); token.AppendTo(ref result, data); } return(result); }