def get_folder_overall_status(path, file_statuses, all_statuses):
    """Returns a 3-tuple of an IndexStatus, WorktreeStatus and MergeStatus,
    chosen based on the most severe of the corresponding statuses of the
    files. file_statuses should be a set of status tuples for individual
    files."""
    if file_statuses:
        index_statuses, worktree_statuses, merge_statuses = zip(*file_statuses)
        index_status = max(index_statuses)
        worktree_status = max(worktree_statuses)
        merge_status = max(merge_statuses)
    else:
        # No files listed. Maybe the directory, or a parent directory, is listed:
        index_status, worktree_status, merge_status = all_statuses.get_status(path)
    return index_status, worktree_status, merge_status