private void BuildTree() { //NamedTag.Name = "Root"; Queue <NodeData> stack = new Queue <NodeData>(20); stack.Enqueue(new NodeData(treeView.Nodes, NamedTag)); while (stack.Count > 0) { NodeData current = stack.Dequeue(); TreeNodeCollection nodes = current.Nodes; Tag data = current.Tag; if (data is CompoundTag) { CompoundTag compound = (CompoundTag)data; TreeNode node = nodes.Add(current.ListIndex != -1 ? current.ListIndex + "" : (compound.Name == "" ? "<NoNameTag>" : compound.Name)); node.ToolTipText = compound.GetType().Name; foreach (Tag tag in compound.Tags.Values) { if (tag is CompoundTag || tag is ListTag) { stack.Enqueue(new NodeData(node.Nodes, tag)); } else { TreeNode child = node.Nodes.Add(tag.Name); child.ToolTipText = tag.GetType().Name; SetTagValue(child, tag); } } } else if (data is ListTag) { int index = 0; ListTag list = (ListTag)data; TreeNode node = nodes.Add(current.ListIndex != -1 ? current.ListIndex + "" : list.Name); node.ToolTipText = list.GetType().Name; foreach (Tag tag in list.Tags) { if (tag is CompoundTag || tag is ListTag) { stack.Enqueue(new NodeData(node.Nodes, tag, index)); } else { TreeNode child = node.Nodes.Add("" + index); child.ToolTipText = tag.GetType().Name; SetTagValue(child, tag); } index++; } } } }