/*
         * //Deserialization constructor.
         * public DynamicBranchTreeNode(SerializationInfo info, StreamingContext context)
         * {
         *  //Describe deserialization
         *  Data = (T)info.GetValue("Data", typeof(T));
         *  Children = (ArrayList)info.GetValue("Nodes", typeof(ArrayList));
         *  Parent = (DynamicBranchTreeNode<T>)info.GetValue("Parent", typeof(DynamicBranchTreeNode<T>));
         * }
         * */

        #endregion

        #region Methods

        //Adds node
        public void AddChild(DynamicBranchTreeNode <T> node)
        {
            //Set parent node
            node.Parent = this;

            //Add to list
            childNodes.Add(node);
        }
        //Recursive clear function
        private void Clear(DynamicBranchTreeNode <T> node)
        {
            //Cycle through children cand call clear
            for (int i = 0; i < node.NodeCount; i++)
            {
                node.GetChild(i).Parent = null;
                Clear(node.GetChild(i));
            }

            //Clear children array
            node.Children.Clear();

            //Return state
            return;
        }
 //Default constructor. Inits objects.
 public DynamicBranchTreeNode()
 {
     childNodes = new ArrayList(3);
     Parent     = null;
     Data       = null;
 }