TerrainDisplay.Collision.BSPTree.FindRootNode C# (CSharp) Method

FindRootNode() private static method

private static FindRootNode ( IList nodes ) : short
nodes IList
return short
        private static short FindRootNode(IList<BSPNode> nodes)
        {
            for (short rootId = 0; rootId < nodes.Count; rootId++)
            {
                var node = nodes[rootId];
                if (node == null) continue;

                var found = false;
                for (var j = 0; j < nodes.Count; j++)
                {
                    // don't check a node against itself
                    if (rootId == j) continue;

                    var parent = nodes[j];
                    if (parent == null) continue;

                    // this node is the child to another node
                    if (parent.posChild != rootId && parent.negChild != rootId) continue;

                    found = true;
                    break;
                }
                if (!found) return rootId;
            }
            return short.MinValue;
        }