function baseStatePredicate(state, full) {
    if (full) {
      return this.extract(state);
    }

    // Cache a state predicate function
    var fn = getPredicateFunction(state);
    return this.flatten(function (node) {
      // Never include removed nodes unless specifically requested
      if (state !== 'removed' && node.removed()) {
        return false;
      }
      return fn(node);
    });
  }
Base function to filter nodes by state value.

@private
@param {string} state State property
@param {boolean} full Return a non-flat hierarchy
@return {TreeNodes} Array of matching nodes.