Added a routine to get an array of terms in a query, in preparation