def find_file_in_parent_dir(subdirectory, filename_pattern):
    current_dir = subdirectory
    while True:
        # See if the current directory contains the desired file:
        for name in os.listdir(current_dir):
            full_path = os.path.join(current_dir, name)
            matches_pattern = fnmatch.fnmatch(name, filename_pattern)
            if matches_pattern and os.path.isfile(full_path):
                return full_path
        # Get the next directory up:
        last_dir = current_dir
        current_dir = os.path.dirname(current_dir)
        # Check to see if we have reached the root directory:
        if last_dir == current_dir:
            return None
Check Origin for cross-site API requests.
dataset/ETHPy150Open SublimeHaskell/SublimeHaskell/sublime_haskell_common.py/find_file_in_parent_dir--crossover with--dataset/ETHPy150Open jupyterhub/jupyterhub/jupyterhub/apihandlers/base.py/APIHandler.check_referer