private static TagValueNode SimplifyTag(TagValueNode node) 
		{
			if (node.Tag.IsExplicit()) 
			{
				EXPLICITTag    exTag = node.Tag as EXPLICITTag;
				SimpleASN1TAG  smTag = exTag.ExtractSimpleOuterTag();

				node.Tag = exTag.underTag;

				TagValueNode tmpNode = SimplifyTag(node);
		
				// node := (novi node)->node...

				ArrayList nodes = new ArrayList();
				nodes.Add(node);
				return Create(smTag, nodes);

			}

			if (node.Tag.IsImplicit()) 
			{
				IMPLICITTag    imTag = node.Tag as IMPLICITTag;
				SimpleASN1TAG  smTag = imTag.ExtractSimpleOuterTag();

				node.Tag = imTag.underTag;
				node = SimplifyTag(node);
				node.Tag = smTag;

				return node;
			}

			return null;
		}
		public void DumpNodeToStream(TagValueNode node) 
		{
			binWriter.Write(node.TagOctets_);
			binWriter.Write(node.LengthOctets_);

			if (node.IsLeaf()) 
			{
				binWriter.Write(node.ValueOctets_);
			}
			else 
			{
				foreach (TagValueNode nod in node.Nodes) 
				{
					DumpNodeToStream(nod);
				}
			}
		}
		/// <summary>
		/// <para>
		/// This method traverses TagValue tree and expands all explicit and implicit tags and 
		/// turns them into simple tags.
		/// </para>
		/// <para>
		/// This is preparation before binary dump. There are no length octets - but now 
		/// when all value octets are expanded they can be easily calculated on the fly.</para>
		/// </summary>
		/// <param name="node">a node representing a TagValue tree</param>
		/// <returns>expanded corresponding tree</returns>
		public static TagValueNode Expand(TagValueNode node) 
		{

			if (!node.Tag.IsSimple())  { node = SimplifyTag(node); }

			if (node.IsLeaf()) 
			{
				node.innerLen = node.ValueOctets.Length;
			}
			else 
			{
				int valueLength = 0;
				for(int i=0; i<node.Nodes.Count; i++) 
				{
					node.Nodes[i] = Expand(node.Nodes[i] as TagValueNode);
					valueLength += (node.Nodes[i] as TagValueNode).outerLen;
				}
				node.innerLen = valueLength;
			}
			
			/// FinishUpNode...
			/// begin
			node.LengthOctets = DERMethods.MakeLengthOctets(node.innerLen);
			node.TagOctets    = DERMethods.MakeTagOctets(node.Tag as SimpleASN1TAG);
			node.outerLen = node.innerLen + node.LengthOctets.Length + node.TagOctets.Length;
			/// end 

			return node;
		}