code: def _ResponseToApprovalsWithGrants(response):
    
    prev_triplet = None
    cur_approval_request = None
    for (approval_id_int, approval_timestamp, approval_request_bytes,
         grantor_username, grant_timestamp) in response:
  
      cur_triplet = (approval_id_int, approval_timestamp, approval_request_bytes)
  
      if cur_triplet != prev_triplet:
        prev_triplet = cur_triplet
  
        if cur_approval_request:
          yield cur_approval_request
  
        cur_approval_request = mysql_utils.StringToRDFProto(
            rdf_objects.ApprovalRequest, approval_request_bytes)
        cur_approval_request.approval_id = _IntToApprovalID(approval_id_int)
        cur_approval_request.timestamp = mysql_utils.TimestampToRDFDatetime(
            approval_timestamp)
  
      if grantor_username and grant_timestamp:
        cur_approval_request.grants.append(
            rdf_objects.ApprovalGrant(
                grantor_username=grantor_username,
                timestamp=mysql_utils.TimestampToRDFDatetime(grant_timestamp)))
  
    if cur_approval_request:
      yield cur_approval_request
docs: Converts a generator with approval rows into ApprovalRequest objects.