/// <summary> /// Finds the leaf node that contains the leaf record if able. /// </summary> /// <param name="item">Item to find</param> /// <param name="rRoot">Tree to search</param> /// <param name="rLeafPath">Path to node from root</param> /// <returns>true if leaf is found</returns> private bool findLeaf(LeafRecord <T> item, ref NodeRecord <T> rRoot, List <NodeRecord <T> > rLeafPath) { NodeRecord <T> node = rRoot; if (!node.Node.IsLeaf()) { foreach (var childNode in node.Node.GetRecords()) { if (childNode.BBox.Overlaps(item.BBox)) { node = (NodeRecord <T>)childNode; if (findLeaf(item, ref node, rLeafPath)) { rLeafPath.Insert(0, node); rRoot = node; return(true); } } } } else { foreach (var childNode in node.Node.GetRecords()) { LeafRecord <T> leaf = (LeafRecord <T>)childNode; if (leaf.IsEqual(item)) { return(true); } } } return(false); }