def diagonal_check_plane_pair(lhs, max_lhs, rhs_valid, board_accessor, player):
    """
    Count the number of diagonal instances given an arbitrary location, maximum, validity functions, accessor, and player comparison
    """
    count = 0
    # Subtract from lhs and rhs until we hit 0 on both
    for delta in range(0, -lhs - 1, -1):
        if not rhs_valid(delta) or board_accessor(delta) != player:
            break
        count += 1
    for delta in range(1, max_lhs - lhs):
        if not rhs_valid(delta) or board_accessor(delta) != player:
            break
        count += 1
    return count