code: def query_to_mdf_records(query=None, dataset_id=None, mdf_acl=None):
      
      if not query and not dataset_id:
          raise ValueError("Either query or dataset_id must be specified")
      if query and dataset_id:
          raise ValueError("Both query and dataset_id were specified; pick one or the other.")
      if not query:
          query = PifSystemReturningQuery(
              query=DataQuery(
                  dataset=DatasetQuery(
                      id=Filter(equal=dataset_id)
                  )
              ),
              size = 10000 # Don't pull down all the results by default
          )
  
      client = get_client()
  
      if not mdf_acl:
          raise ValueError('Access controls (mdf_acl) must be specified.  Use ["public"] for public access')
  
      pif_result = client.pif_search(query)
      if len(pif_result.hits) == 0:
          return []
  
      example_uid = pif_result.hits[0].system.uid
      dataset_query = DatasetReturningQuery(
          query=DataQuery(
              system=PifSystemQuery(
                  uid=Filter(equal=example_uid)
              )
          ),
          size = 1 # we only expect one dataset to hit
      )
  
      dataset_result = client.dataset_search(dataset_query)
  
      records = []
      for hit in pif_result.hits:
          records.append(pif_to_mdf_record(hit.system, dataset_result.hits[0], mdf_acl))
  
      return records
docs: Evaluate a query and return a list of MDF records
  
      If a datasetID is specified by there is no query, a simple
      whole dataset query is formed for the user