var filterDown = function(root, queryParts) {
// NOTE:
// this is the guts of the DOM query system. It takes a list of
// parsed query parts and a root and finds children which match
// the selector represented by the parts
var candidates = getArr(root), qp, x, te, qpl = queryParts.length, bag, ret;
for (var i = 0; i < qpl; i++) {
ret = [];
qp = queryParts[i];
x = candidates.length - 1;
if (x > 0) {
// if we have more than one root at this level, provide a new
// hash to use for checking group membership but tell the
// system not to post-filter us since we will already have been
// gauranteed to be unique
bag = {};
ret.nozip = true;
}
var gef = getElementsFunc(qp);
for (var j = 0; te = candidates[j]; j++) {
// for every root, get the elements that match the descendant
// selector, adding them to the 'ret' array and filtering them
// via membership in this level's bag. If there are more query
// parts, then this level's return will be used as the next
// level's candidates
gef(te, ret, bag);
}
if (!ret.length) { break; }
candidates = ret;
}
return ret;
};