public static ReadOnlyCollection<SystemNode> GetNodes(Stream stream, int index) { List<SystemNode> retVal = new List<SystemNode>(); byte endCheck = 0; do { SystemNode nd = new SystemNode(stream, index); index += nd.DataLength; retVal.Add(nd); if (index < stream.Length) { stream.Position = index; endCheck = Convert.ToByte(stream.ReadByte()); } } while (endCheck != 255 && index < stream.Length); return new ReadOnlyCollection<SystemNode>(retVal); }