code: def find_apikey():
      
      env_keys = ['TINYPNG_APIKEY', 'TINYPNG_API_KEY']
      paths = []
      paths.append(os.path.join(os.path.abspath("."), "tinypng.key"))  # local directory
      paths.append(os.path.expanduser("~/.tinypng.key"))  # home directory
  
      for env_key in env_keys:
          if os.environ.get(env_key):
              return os.environ.get(env_key)
  
      for path in paths:
          if os.path.exists(path):
              return open(path, 'rt').read().strip()
  
      return None
docs: Finds TinyPNG API key
  
      Search for api key in following order:
       - environment variable TINYPNG_APIKEY
       - environment variable TINYPNG_API_KEY
       - file in local directory tinypng.key
       - file in home directory ~/.tinypng.key
  
      If key not found returns None