public function extend($basedir = null, $overwrite = false)
    {
        if (null === $basedir) {
            $basedir = $this->basedir;
        }

        $basedir = File::realpath($basedir);

        if (false === $this->loadFromCache($basedir)) {
            $this->loadFromBaseDir($basedir, $overwrite);
            $this->saveToCache($basedir);
        }

        if (
            !empty($this->environment)
            && false === strpos($this->environment, $basedir)
            && is_dir($basedir.DIRECTORY_SEPARATOR.$this->environment)
        ) {
            $this->extend($basedir.DIRECTORY_SEPARATOR.$this->environment, $overwrite);
        }

        return $this;
    }