public function replaceChild($index, $subs)
    {
        $first = array_slice($this->children, 0, $index);
        $second = $index + 1 >= count($this->children) ? [] : array_slice($this->children, $index + 1, count($this->children) - ($index + 1));

        $this->children = [];

        foreach (array_merge($first, $subs, $second) as $child) {
            if ($child) {
                $this->addChild($child);
            }
        }
        $this->flush();

        return $this;
    }