protected function findConfigFile(OutputInterface $output): ?string
    {
        $directory = @getcwd();
        if ($directory === false) {
            throw new \RuntimeException('Can\'t get the working directory path. Make sure the working directory is readable.');
        }

        for ($i = 0; $i < 10000; ++$i) { // `for` protects from an infinite loop
            $file = $directory . DIRECTORY_SEPARATOR . $this->getCommandStaticConfigFilename();

            if (@is_file($file)) {
                return $file;
            }

            $parentDirectory = @realpath($directory.DIRECTORY_SEPARATOR.'..'); // Gets the parent directory path

            // Check whether the parent directory is restricted
            if ($parentDirectory === false) {
                if ($output->isVerbose()) {
                    $output->writeln('The parent directory of `'.$directory.'` is restricted (maybe by open_basedir)'
                        . ', so the search of a configuration file can\'t be proceeded');
                }
                break;
            }

            if ($parentDirectory === $directory) break; // Check whether the current directory is a root directory
            $directory = $parentDirectory;
        }

        return null;
    }