private int GetNumberOfNodes(GenericNAryTreeNode <T> node)
        {
            var count = node.GetNumberOfChildren();

            foreach (var child in node.Children)
            {
                count += GetNumberOfNodes(child);
            }
            return(count);
        }
        private GenericNAryTreeNode <T> Find(GenericNAryTreeNode <T> nodeToFind, GenericNAryTreeNode <T> currentNode)
        {
            GenericNAryTreeNode <T> returnNode = null;

            if (currentNode != null)
            {
                if (currentNode.Equals(nodeToFind))
                {
                    returnNode = currentNode;
                }
                else if (currentNode.HasChildren())
                {
                    int i = 0;
                    while (returnNode == null && i < currentNode.GetNumberOfChildren())
                    {
                        returnNode = Find(nodeToFind, currentNode.Children[i]);
                        i++;
                    }
                }
            }
            return(null);
        }
 public bool Exists(GenericNAryTreeNode <T> node)
 {
     return(Find(node, root) != null);
 }
 public bool Equals(GenericNAryTreeNode <T> other)
 {
     return(this.data.Equals(other.data));
 }
 public void AddChild(GenericNAryTreeNode <T> child)
 {
     children.Add(child);
 }