public function setMaxDepth(int $maxDepth) : void
    {
        if ($maxDepth < 0 || $maxDepth >= 0x7fffffff) { // max depth + 1 must not be greater than this limit
            throw new \InvalidArgumentException('Invalid max depth.');
        }

        $this->maxDepth = $maxDepth;
    }