static void addNode(FBXNode parent, FBXNode child)
 {
     if (child == null)
     {
         return;
     }
     parent.nodes.Add(child);
 }
        static FBXNode new_node(StreamReader sr, string line)
        {
            if (!line.Contains(":") || isComment(line))
            {
                return(null);
            }

            FBXNode node = new FBXNode();

            if (line.Contains("{"))
            {
                string next = "";
                while (!next.Contains("}"))
                {
                    next = sr.ReadLine();
                    if (!next.Contains("}"))
                    {
                        addNode(node, new_node(sr, next));
                    }
                }
            }

            string[] split1 = line.Split(':');
            node.Name = split1[0].Replace("\t", "");

            string props = line.Remove(0, split1[0].Length + 1);

            props = props.Remove(props.Length - 1, 1);
            string[] propsSplit = props.Split(',');
            if (propsSplit.Length > 0)
            {
                for (int i = 0; i < propsSplit.Length; i++)
                {
                    if (IsNullOrWhiteSpace(propsSplit[i]))
                    {
                        continue;
                    }

                    if (node.properties == null)
                    {
                        node.properties = new List <string>();
                    }

                    if (propsSplit[i][0] == ' ')
                    {
                        node.properties.Add(propsSplit[i].Remove(0, 1));
                    }
                    else
                    {
                        node.properties.Add(propsSplit[i]);
                    }
                }
            }

            return(node);
        }
        private FBXNode findRecursive(FBXNode node, string[] path, int index)
        {
            FBXNode result = node.nodes.FirstOrDefault(x => x.Name == path[index]);

            if (path.Length < index + 1)
            {
                findRecursive(result, path, index++);
                return(result);
            }
            else
            {
                return(result);
            }
        }
        /// <summary>
        /// Search for a single node
        /// path = "SomeRootNode/SubNode1/Subnode2..."
        /// Will return first found even if multiple exists, use with caution
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public FBXNode FindNode(string path)
        {
            FBXNode result = null;

            try {
                string[] split = path.Split('/');
                FBXNode  root  = nodes.FirstOrDefault(x => x.Name == split[0]);
                if (split.Length > 1)
                {
                    result = findRecursive(root, split, 1);
                }
                else
                {
                    result = root;
                }
            }
            catch (Exception e) {
                Debug.LogError("Node could not be found");
                Debug.LogError(e.Message);
                Debug.LogError(e.StackTrace);
            }
            return(result);
        }