private Node Insert(final Rectangle aRect)
        {
            if (children != null) // not  a leaf
            {
                // try inserting into first child
                Node node = children[0].Insert(aRect);
                if (node != null)
                    return node;

                // no room, insert into second
                return children[1].Insert(aRect);
            }
            else
            {
                if (bTaken)
                    return null;

                if (    aRect.width > this.rect.width
                    ||  aRect.height > this.rect.height)
                {
                    // node is too small, rect can't fit inside
                    return null;
                }

                if (    aRect.width == this.rect.width
                    &&  aRect.height == this.rect.height)
                {
                    // fits perfectly
                    this.bTaken = true;
                    return this;
                }

                // otherwise split node and create kids
                children = new Node[2];
                children[0] = new Node();
                children[1] = new Node();

                // decide which way to split
                int dw = this.rect.width - aRect.width;
                int dh = this.rect.height - aRect.height;

                if (dw > dh)
                {
                    children[0].rect = new Rectangle(   this.rect.x,
                                                        this.rect.y,
                                                        aRect.width,
                                                        this.rect.height);

                    children[1].rect = new Rectangle(   this.rect.x + aRect.width,
                                                        this.rect.y,
                                                        this.rect.width - aRect.width,
                                                        this.rect.height);
                }
                else
                {
                    children[0].rect = new Rectangle(   this.rect.x,
                                                        this.rect.y,
                                                        this.rect.width,
                                                        aRect.height);

                    children[1].rect = new Rectangle(   this.rect.x,
                                                        this.rect.y + aRect.height,
                                                        this.rect.width,
                                                        this.rect.height - aRect.height);
                }

                // insert into first child we created
                return children[0].Insert(aRect);
            }
        }