private bool Delete(Utils.LineWHistory _line)
        {
            if (_line == null)
            {
                return(false);
            }

            bool deletedLine = false;

            // try deleting in this node
            foreach (var line in this.nodeLines)
            {
                if (line.ID == _line.ID)
                {
                    this.nodeLines.Remove(line);
                    deletedLine = true;
                    break;
                }
            }

            // if not successful, try in the child nodes
            if (!deletedLine && this.hasChildren())
            {
                for (int flags = this.activeNodes, index = 0; flags > 0; flags >>= 1, index++)
                {
                    if ((flags & 1) == 1)
                    {
                        deletedLine = this.childNodes[index].Delete(_line);
                        if (deletedLine)
                        {
                            break;
                        }
                    }
                }
            }

            return(deletedLine);
        }
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // ====================================== PRIVATE MODIFICATION METHODS ==================================== //
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////

        #region Tree MODIFICATION ( INSERT, DELETE, PRUNE)
        private bool Insert(Utils.LineWHistory _line)
        {
            if (_line == null)
            {
                return(false);
            }

            BoundingBox bb = _line.BB;

            if (this.region.Contains(ref bb) != ContainmentType.Contains)
            {
                // something went wrong OR the tree needs to be rebuilt,
                // because the line is not contained in the root node
                return(false);
            }

            bool insertedLine = false;

            // try inserting it in any of the children nodes
            BoundingBox[] octants = getChildRegions(this.region, this.minVolSize);
            for (int index = 0; index < 8; index++)
            {
                if (this.childNodes[index] != null)
                {
                    // existing child node
                    if (this.childNodes[index].region.Contains(ref bb) == ContainmentType.Contains)
                    {
                        insertedLine = this.childNodes[index].Insert(_line);
                    }
                    if (insertedLine && !this.childNodes[index].TreeBuilt)
                    {
                        this.childNodes[index].BuildTree(this.minVolSize);
                        break;
                    }
                }
                else
                {
                    // possible new child node
                    if ((octants != null) && (octants[index].Contains(ref bb) == ContainmentType.Contains))
                    {
                        this.childNodes[index] = createNode(octants[index], new List <Utils.LineWHistory>()
                        {
                            _line
                        }, this.minVolSize);
                        this.activeNodes |= (byte)(1 << index);
                        // this.childNodes[index].BuildTree(this.minVolSize);
                        insertedLine = true;
                        break;
                    }
                }
            }

            // if none of the children could take the line, it remains in this node
            if (!insertedLine)
            {
                this.nodeLines.Add(_line);
                insertedLine = true;
            }

            return(insertedLine);
        }