protected function parseConfigYaml($filename, DirectoryInterface $directory = null)
    {
        $directory = $directory ?: $this->app['filesystem']->getDir('config://');

        try {
            $file = $directory->get($filename);
        } catch (FileNotFoundException $e) {
            // Copy in dist files if applicable
            $distFiles = ['config.yml', 'contenttypes.yml', 'menu.yml', 'permissions.yml', 'routing.yml', 'taxonomy.yml'];
            if ($directory->getMountPoint() !== 'config' || !in_array($filename, $distFiles)) {
                return [];
            }

            $this->app['filesystem']->copy("bolt://app/config/$filename.dist", "config://$filename");
            $file = $directory->get($filename);
        }

        if (!$file instanceof ParsableInterface) {
            throw new \LogicException('File is not parsable.');
        }

        $yml = $file->parse() ?: [];

        // Unset the repeated nodes key after parse
        unset($yml['__nodes']);

        return $yml;
    }