int SerializeNode(TreeGraphNode node)
        {
            var data = new TreeNodeData
            {
                position = node.GetPosition().position,                                                 //Position
                nodeTypeSerializableName = node.Info.serializedName,                                    //Node type name
                parameters = node.Parameters                                                            //Parameters
            };

            //Children
            if (node.ChildrenPort == null || !node.ChildrenPort.connected)
            {
                data.children = Array.Empty <int>();
            }
            else
            {
                var childIndices = new List <int>();

                foreach (Edge connection in node.ChildrenPort.connections)
                {
                    if (!(connection.input.node is TreeGraphNode child))
                    {
                        continue;
                    }

                    while (child.Order >= childIndices.Count)
                    {
                        childIndices.Add(-1);
                    }
                    childIndices[child.Order] = SerializeNode(child);
                }

                data.children = childIndices.ToArray();
            }

            //Finalize
            data.GUID = allData.Count;

            allData.Add(data);
            return(data.GUID);
        }