boolean (@NotNull PyFile file, @NotNull String source) { final QualifiedName sourceQName = QualifiedName.fromDottedString(source); return Stream.concat( file.getFromImports().stream().map(PyFromImportStatement::getImportSourceQName), file.getImportTargets().stream().map(PyImportElement::getImportedQName) ) .filter(Objects::nonNull) .anyMatch(name -> name.matchesPrefix(sourceQName)); }