code: def canon_pairwise_wql(query: dict = None) -> dict:
      
  
      if not query:
          return {
              '~their_did': {
                  '$neq': ''
              }
          }
  
      for k in [qk for qk in query]:  # copy: iteration alters query keys
          if isinstance(query[k], dict):  # only subqueries are dicts: recurse
              query[k] = canon_pairwise_wql(query[k])
          if k == '$or':
              if not isinstance(query[k], list):
                  raise BadWalletQuery('Bad WQL; $or value must be a list in {}'.format(json.dumps(query)))
              query[k] = [canon_pairwise_wql(subq) for subq in query[k]]
          elif k == '$not':
              query[k] = canon_pairwise_wql(query.pop(k))
          elif k not in WQL_1_OPS:
              qkey = canon_pairwise_tag(k)
              query[qkey] = query.pop(k)
              tag_value = query[qkey]
              if isinstance(tag_value, dict) and len(tag_value) == 1:
                  if '$in' in tag_value:
                      tag_value['$in'] = [raw(val) for val in tag_value['$in']]
                  else:
                      wql_op = set(tag_value.keys()).pop()  # $neq, $gt, $gt, etc.
                      tag_value[wql_op] = raw(tag_value[wql_op])
              else:
                  query[qkey] = raw(query.pop(qkey))
  
      return query
docs: Canonicalize WQL tags to unencrypted storage specification.
      Canonicalize comparison values to strings via raw().
  
      Raise BadWalletQuery for WQL mapping '$or' to non-list.
  
      :param query: WQL query
      :return: canonicalized WQL query dict