protected function fileUrlAndKey($key)
    {

        if (isset($this->keyUrlCache[$key])) {
            return $this->keyUrlCache[$key];
        }

        $parts = explode('.', $key);
        $url = $this->urlOrFail();
        $partCount = count($parts);

        if ($partCount <= $this->nestingLevel) {
            $minLength = $this->nestingLevel+1;
            $msg = "The key segments has to have a minimum count of $minLength (nesting level: $this->nestingLevel)";
            throw (new KeyLengthException($msg))->setMinSegments($minLength);
        }

        $subKey = [];

        for ($i=0; $i<$partCount; $i++) {


            if ($i < $this->nestingLevel) {
                $url = $url->append($parts[$i]);
                continue;
            }


            if ($i == $this->nestingLevel) {
                $url = $url->append($this->fileName($parts[$i]));
                continue;
            }

            $subKey[] = $parts[$i];
        }

        $this->keyUrlCache[$key] = [$url, implode('.', $subKey)];

        return $this->keyUrlCache[$key];

    }