public function findParentByFile($fileName, $directory = null)
    {
        if (empty($fileName)) {
            throw new InvalidArgumentException('$fileName (value was ' . $fileName . ') must be set.', 1525785151);
        }

        $directory = $directory ?? getcwd();
        $hit = null;

        while ($directory !== $this->environment->getRootDirectory()
            && $directory !== ''
            && $directory !== '.'
            && $directory !== '/'
        ) {
            if ($this->filesystem->exists($directory . '/' . $fileName)) {
                $hit = $directory;
                break;
            }
            $directory = dirname($directory);
        }

        return $hit;
    }