public function get(?string $key = null)
    {
        $key = $this->constructKey($key);

        if (is_null($key)) {
            $array = $this->toArray();

            return $this->count() == 1 ? end($array) : $array;
        }

        return $this->parseKey($key, function ($part, $result) {
            if (isset($result[$part])) {
                return $result[$part];
            }
        });
    }