public void DisplayData(byte[] data)
        {
            Clear();

            TreeNode root   = null;
            TreeNode parent = null;
            var      remainingCountStack = new Stack <int>();
            var      remainingCount      = 1;

            using (var stream = new MemoryStream(data))
                using (var reader = new MsgPackReader(stream))
                {
                    try
                    {
                        while (reader.ReadNext())
                        {
                            var node = CreateNode(reader);
                            if (parent != null)
                            {
                                parent.Nodes.Add(node);
                            }
                            else
                            {
                                root   = node;
                                parent = node;
                            }
                            remainingCount--;

                            if (reader.IsArray || reader.IsMap)
                            {
                                remainingCountStack.Push(remainingCount);
                                remainingCount = reader.ChildObjectCount;
                                parent         = node;
                            }

                            while ((remainingCount == 0) && (remainingCountStack.Count > 0))
                            {
                                remainingCount = remainingCountStack.Pop();
                                parent         = parent.Parent;
                            }
                            if ((remainingCount == 0) && (remainingCountStack.Count == 0))
                            {
                                break;
                            }
                        }

                        if (reader.ReadNext())
                        {
                            throw new Exception("content after the root node");
                        }
                    }
                    catch (Exception ex)
                    {
                        var message = String.Format("Error at byte {0}: {1}", stream.Position, ex.Message);
                        var node    = CreateNode(message, ex.ToString());
                        if (root == null)
                        {
                            root = node;
                        }
                        else
                        {
                            root.Nodes.Add(node);
                        }
                    }
                }

            if (root != null)
            {
                tree.Nodes.Add(root);
                tree.ExpandAll();
                tree.SelectedNode = root;
            }
        }
        public void DisplayData(byte[] data)
        {
            Clear();

            TreeNode root = null;
            TreeNode parent = null;
            var remainingCountStack = new Stack<int>();
            var remainingCount = 1;

            using (var stream = new MemoryStream(data))
            using (var reader = new MsgPackReader(stream))
            {
                try
                {
                    while (reader.ReadNext())
                    {
                        var node = CreateNode(reader);
                        if (parent != null)
                            parent.Nodes.Add(node);
                        else
                        {
                            root = node;
                            parent = node;
                        }
                        remainingCount--;

                        if (reader.IsArray || reader.IsMap)
                        {
                            remainingCountStack.Push(remainingCount);
                            remainingCount = reader.ChildObjectCount;
                            parent = node;
                        }

                        while ((remainingCount == 0) && (remainingCountStack.Count > 0))
                        {
                            remainingCount = remainingCountStack.Pop();
                            parent = parent.Parent;
                        }
                        if ((remainingCount == 0) && (remainingCountStack.Count == 0))
                            break;
                    }

                    if (reader.ReadNext())
                        throw new Exception("content after the root node");
                }
                catch (Exception ex)
                {
                    var message = String.Format("Error at byte {0}: {1}", stream.Position, ex.Message);
                    var node = CreateNode(message, ex.ToString());
                    if (root == null)
                        root = node;
                    else
                        root.Nodes.Add(node);
                }
            }

            if (root != null)
            {
                tree.Nodes.Add(root);
                tree.ExpandAll();
                tree.SelectedNode = root;
            }
        }