def find_latest_iteration(directories):
    """
        Selects the latest iteration of a workflow based on the numbering
        of directories.
        Expects a list of directories of the form
        <path>/<name>_<number>
        and will return the directory with the highest number.
        Will return 0 if no directories are given.
    """
    numbers = [0]
    for d in directories:
        number_string = d.split('_')[-1].replace('/','')
        number = int(number_string)
        numbers.append(number)
    return max(numbers)