code: function gatherEntityFilters(context, expression) {
      let ii, len, bf, result, obj;
  
      let filter = expression[0];
      result = EntityFilter.create();
  
      switch (filter) {
          case ANY:
          case ANY_FILTER:
          case ALL:
          case ALL_FILTER:
          case NONE:
          case NONE_FILTER:
          case INCLUDE:
          case INCLUDE_FILTER:
              if (expression[1] === ROOT) {
                  result.add(ROOT);
              } else {
                  obj = context.valueOf(expression[1], true);
  
                  if (!obj) {
                      if (filter == ALL_FILTER) {
                          result.add(ROOT);
                          return;
                      }
                      return null;
                  }
                  bf = context.componentsToBitfield(context, obj);
  
                  // filter = expression[0];
                  switch (filter) {
                      case ALL_FILTER:
                          filter = ALL;
                          break;
                      case ANY_FILTER:
                          filter = ANY;
                          break;
                      case NONE_FILTER:
                          filter = NONE;
                          break;
                      case INCLUDE_FILTER:
                          filter = INCLUDE;
                          break;
                      default:
                          break;
                  }
                  // console.log('CONVERTED TO BF', filter, bf.toString(), bf.toJSON() );
                  result.add(filter, bf);
              }
              break;
          case AND:
              expression = expression.slice(1); // _.rest(expression);
  
              for (ii = 0, len = expression.length; ii < len; ii++) {
                  obj = gatherEntityFilters(context, expression[ii]);
                  if (!obj) {
                      return null;
                  }
                  result.filters = result.filters.concat(obj.filters);
              }
              break;
          default:
              return null;
      }
  
      return result;
  }
docs: Query functions for the memory based entity set.
  
  Some inspiration taken from https://github.com/aaronpowell/db.js