List<PyImportStatementBase> (@Nullable PsiElement importBlockStart) { if (importBlockStart == null) return null; final List<PyImportStatementBase> importsAllowedToReuse = new ArrayList<>(); PsiElement candidate = importBlockStart; while (candidate instanceof PyImportStatementBase) { importsAllowedToReuse.add((PyImportStatementBase)candidate); candidate = PyPsiUtils.getNextNonWhitespaceSibling(candidate); } return importsAllowedToReuse; }