def winner(board):
    """
    Returns the winner of the game, if there is one.
    """
    # Iterates through the rows and finds winning patterns.
    for i in range(3):
        if board[i][0] == board[i][1] == board[i][2] is not None:
            return board[i][0]

    # Iterates through the columns and finds winning patterns
    for i in range(3):
        if board[0][i] == board[1][i] == board[2][i] is not None:
            return board[0][i]

    # Checks for diagonal winning patterns
    if board[0][0] == board[2][2] == board[1][1] is not None:
        return board[1][1]

    if board[2][0] == board[0][2] == board[1][1] is not None:
        return board[1][1]

    # If none of the conditions above are met, there are no winners.
    return None