Node CopyNode(Node tree)
        {
            Node newtree = new ConstNode(null, 0);

            if (tree is FuncNode)
            {
                newtree = new FuncNode(null, (tree as FuncNode).function);
                for (int i = 0; i < (tree as FuncNode).children.Count; i++)
                {
                    Node child = CopyNode((tree as FuncNode).children[i]);
                    child.parent = newtree;
                    (newtree as FuncNode).children.Add(child);
                }
            }
            if (tree is VariableNode)
            {
                return(new VariableNode(null, (tree as VariableNode).variable));
            }
            if (tree is ConstNode)
            {
                return(new ConstNode(null, (tree as ConstNode).constant));
            }

            return(newtree);
            //Node Newindividual = new Node(Newindividual.parent);
        }
        Node GenerateFullTree()
        {
            int depth = rand.Next(minDepth, maxDepth + 1);
            int ltc   = depth;

            int  index = rand.Next(functions.Count);
            Node root  = new FuncNode(null, functions[index]);

            GenerateTree(root, ltc);

            return(root);
        }