code: def which(filename, env=None):
      """This takes a given filename; tries to find it in the environment path;
      then checks if it is executable. This returns the full path to the filename
      if found and executable. Otherwise this returns None."""
  
      # Special case where filename contains an explicit path.
      if os.path.dirname(filename) != "" and is_executable_file(
          filename
      ):
          return filename
      if env is None:
          env = os.environ
      p = env.get("PATH")
      if not p:
          p = os.defpath
      pathlist = p.split(os.pathsep)
      for path in pathlist:
          ff = os.path.join(path, filename)
          if is_executable_file(ff):
              return ff
      return None
  
file_path: catboost/contrib/python/pexpect/py2/pexpect/utils.py
imports: import os
  import sys
  import stat
  import select
  import time
  import errno
label_desc: Use image node_id 2 for calling a global function with example usage: which(filename, env) and returns: None, filename, ff