'Join the given TestView QuerySet to IterationResult for one result.
The resulting query looks like a TestView query but has one row per
iteration.  Each row includes all the attributes of TestView, an
attribute for each key in result_keys and an iteration_index attribute.
We accomplish this by joining the TestView query to IterationResult
once per result key.  Each join is restricted on the result key (and on
the test index, like all one-to-many joins).  For the first join, this
is the only restriction, so each TestView row expands to a row per
iteration (per iteration that includes the key, of course).  For each
subsequent join, we also restrict the iteration index to match that of
the initial join.  This makes each subsequent join produce exactly one
result row for each input row.  (This assumes each iteration contains
the same set of keys.  Results are undefined if that\'s not true.)'

def _join_iteration_results(self, test_view_query_set, result_keys):

    if (not result_keys):
        return test_view_query_set
    (query_set, first_alias) = self._join_one_iteration_key(test_view_query_set, result_keys[0])
    for result_key in result_keys[1:]:
        (query_set, _) = self._join_one_iteration_key(query_set, result_key, first_alias=first_alias)
    return query_set
