PyiFile (@NotNull PyFile file) { final QualifiedName name = QualifiedNameFinder.findCanonicalImportPath(file, file); if (name == null) { return null; } final PyQualifiedNameResolveContext context = PyResolveImportUtil.fromFoothold(file); return PyUtil.as(PyResolveImportUtil.resolveQualifiedName(name, context) .stream() .findFirst() .map(PyUtil::turnDirIntoInitPyi) .orElse(null), PyiFile.class); }