def UpdateFilterStatement(statement, query, values, last_id):
  """Updates the FilterStatement in order to page through results.

  Args:
    statement: an instantiated FilterStatement.
    query: a str query that will be used to update the FilterStatement.
    values: a list of bind variables to be updated.
    last_id: a str representing the earliest change ID in a result set.

  Returns:
    FilterStatement the updated statement.
  """
  # Use the earliest change ID in the result set to page.
  updated_values = [{
      'key': 'id',
      'value': {
          'xsi_type': 'TextValue',
          'value': last_id
      }
  }]
  updated_values.extend(values)

  statement.where_clause = query
  statement.values = updated_values

  return statement