Flattens a query tree to its unique positive (non-negated) terms. Used by
backends that only offer a single OR-ish full-text search field (e.g. Magento
search): send all positive terms as one query to get a broad candidate pool,
then refine with the client-side boolean predicate.
Expands a query tree into the distinct reagent names it searches for. Each positive AND-group
(see extractOrGroups) becomes one name by joining its words with a space, so
(sodium OR potassium) hydroxide OR potassium carbonate yields three names. Bare purity
tokens like 99% are dropped, and names are de-duplicated case-insensitively.
Extracts the positive (non-negated) OR-groups from a query tree as a disjunctive-normal-form-ish list: the outer array is OR-ed alternatives, and each inner array is an AND-group of phrases. Negated branches are dropped, since a keyword-only backend has nothing positive to search for in them.