boolean (@NotNull PyReferenceExpression importSource) { final PsiDirectory currentFileDirectory = importSource.getContainingFile().getContainingDirectory(); if (currentFileDirectory != null && PyUtil.isPackage(currentFileDirectory, true, importSource)) { final PyResolveContext resolveContext = PyResolveContext.defaultContext(myTypeEvalContext); return StreamEx .of(importSource.getReference(resolveContext).multiResolve(false)) .map(ResolveResult::getElement) .select(PyFile.class) .map(PsiFile::getContainingDirectory) .nonNull() .map(PsiDirectory::getVirtualFile) .anyMatch(importedSourceDir -> VfsUtilCore.isAncestor(importedSourceDir, currentFileDirectory.getVirtualFile(), false)); } return false; }