def METHOD_NAME(path, exename: str) -> Optional[str]:
    is_win = sys.platform.startswith("win")
    if is_win:
        exename = "%s.exe" % exename
    for bindir in path.split(os.pathsep):
        full_name = os.path.join(bindir, exename)
        if os.path.exists(full_name) and os.path.isfile(full_name):
            if not is_win and not os.access(full_name, os.X_OK):
                continue
            return full_name
    return None