def most_recent(path, startswith=None, endswith=None):
    """Recursively inspect all files under a directory and return the most recent

        Args:
            path (str): the path of the directory to traverse
            startswith (str): the file name start with (optional)
            endswith (str): the file name ends with (optional)
        Returns:
            the most recent file within the subdirectory
    """
    candidate_files = []
    for filename in all_files_in_directory(path):
        if startswith and not os.path.basename(filename).startswith(startswith):
            continue
        if endswith and not filename.endswith(endswith):
            continue
        candidate_files.append({'name': filename, 'modtime': os.path.getmtime(filename)})

    # Return the most recent modtime
    most_recent = sorted(candidate_files, key=lambda k: k['modtime'], reverse=True)
    return most_recent[0]['name'] if most_recent else None