def _load_api_key_from_env_file() -> Optional[str]:
        """
        Try to load the SERPER_API_KEY from a .env file using python-dotenv.
        
        Returns:
            The API key if found in .env file, None otherwise
        """
        try:
            # Try to import dotenv
            from dotenv import load_dotenv
        except ImportError:
            raise ImportError("python-dotenv is not installed. Please install it with 'pip install python-dotenv'")
        
        # Check for .env file in current directory and parent directories
        current_dir = pathlib.Path.cwd()
        
        # Look in current directory and up to 3 parent directories
        for _ in range(4):
            env_path = current_dir / '.env'
            if env_path.exists():
                # Load the .env file
                load_dotenv(dotenv_path=env_path)
                
                # Check if SERPER_API_KEY is now in environment
                if "SERPER_API_KEY" in os.environ:
                    return os.environ["SERPER_API_KEY"]
            
            # Move to parent directory
            parent_dir = current_dir.parent
            if parent_dir == current_dir:  # Reached root directory
                break
            current_dir = parent_dir
        
        return None

        Try to load the SERPER_API_KEY from a .env file using python-dotenv.
        
        Returns:
            The API key if found in .env file, None otherwise
        
src/upsonic/tools.py