Is it possible to "if" an "import"
That question doesn't make sense. import statements allow the code to be written without adding the package name.
There is no requirement to use import statements. Most, maybe all, code can be written without using any import statements.
But what does the code do if it doesn't find the package that the import is refferred to
Try writing a small program with an import statement for a package that does not exist. The compiler will tell you that it can not find the package.