private IEnumerable <(CollisionBlock block, float distance)> FindBlocks(Ray ray)
        {
            var leftBottom = _center - Vector3.one * (_sideSize / 2.0f + Oversize);
            var rightTop   = _center + Vector3.one * (_sideSize / 2.0f + Oversize);
            var distance   = CollisionAlgorithms.RayAABB(ray, leftBottom, rightTop);

            if (distance < 0)
            {
                return(Array.Empty <(CollisionBlock, float)>());
            }
            if (_children.Count == 0)
            {
                return new[] { (this, distance) }
        public int?FindItem(Ray ray, float radius)
        {
            var blocks = FindBlocks(ray).ToList();

            blocks.Sort((i, j) => Comparer <float> .Default.Compare(i.distance, j.distance));

            int?  minId       = null;
            float minDistance = float.MaxValue;

            foreach (var(block, _) in blocks)
            {
                foreach (var(id, pos) in block._items)
                {
                    if (CollisionAlgorithms.RaySphere(ray, pos, radius) &&
                        (pos - ray.origin).magnitude < minDistance)
                    {
                        minId = id;
                    }
                }
            }

            return(minId);
        }