code: def split_expression_by_depth(where, schema, output=None, var_to_depth=None):
      
      """
      It is unfortunate that ES can not handle expressions that
      span nested indexes.  This will split your where clause
      returning {"and": [filter_depth0, filter_depth1, ...]}
      """
      vars_ = where.vars()
  
      if var_to_depth is None:
          if not vars_:
              return Null
          # MAP VARIABLE NAMES TO HOW DEEP THEY ARE
          var_to_depth = {
              v.var: max(len(c.nested_path) - 1, 0) for v in vars_ for c in schema[v.var]
          }
          all_depths = set(var_to_depth.values())
          if len(all_depths) == 0:
              all_depths = {0}
          output = wrap([[] for _ in range(MAX(all_depths) + 1)])
      else:
          all_depths = set(var_to_depth[v.var] for v in vars_)
  
      if len(all_depths) == 1:
          output[first(all_depths)] += [where]
      elif is_op(where, AndOp_):
          for a in where.terms:
              split_expression_by_depth(a, schema, output, var_to_depth)
      else:
          Log.error("Can not handle complex where clause")
  
      return output
docs: :param where: EXPRESSION TO INSPECT
      :param schema: THE SCHEMA
      :param output:
      :param var_to_depth: MAP FROM EACH VARIABLE NAME TO THE DEPTH
      :return: