public function flush()
    {
        $n = 0;
        $children = [];
        foreach ($this->children as $k => $child) {
            if ($child !== null) {
                $child->setIndex($n);
                $child->setParent($this);
                $children[] = $child;
                ++$n;
            }
        }

        $this->children = $children;

        return $this;
    }