private function removeEmptyDirectories($pathname, $root)
    {
        if (is_dir($pathname)
            && $pathname !== $root
            && $this->filesystem->isDirEmpty($pathname)
        ) {
            $this->filesystem->removeDirectory($pathname);

            if (!$this->removeEmptyDirectories(dirname($pathname), $root)) {
                if ($this->io->isVeryVerbose()) {
                    $this->io->writeError(sprintf('  - Removing empty directory "%s"', $pathname));
                }
            }

            return true;
        }

        return false;
    }