code: def _filter_keys(self, content_id=None, prefix=None, subtopic_id=None):
          '''Filter out-of-order labels by key tuple.
          :class:`Label` always sorts by `(cid1,cid2,sid1,sid2)`, but
          for efficient lookups on `cid2` this class also stores in
          order `(cid2,cid1,sid2,sid1)`.  Filter out things that are
          in the wrong order.  But, if an original query specified
          `content_id` or `subtopic_id`, account for the possibility
          that something might be apparently out-of-order but its
          dual will not be in the query at all.
          '''
          def accept(kvp):
              (content_id1, content_id2, subtopic_id1, subtopic_id2,
               annotator_id, inverted_epoch_ticks) = kvp[0]
              is_sorted = (content_id1 < content_id2 or
                           (content_id1 == content_id2 and
                            subtopic_id1 <= subtopic_id2))
              if content_id is not None:
                  assert content_id1 == content_id
              elif prefix is not None:
                  assert content_id1.startswith(prefix)
                  if content_id2.startswith(prefix) and not is_sorted:
                      return False
              elif not is_sorted:
                  return False
              if subtopic_id is None:
                  if content_id2 != content_id:
                      return True
                  return subtopic_id1 <= subtopic_id2
              if subtopic_id == subtopic_id1:
                  return True
              if content_id == content_id2 and subtopic_id == subtopic_id2:
                  return True
              return False
          return accept