Process arguments to query methods. For internal use only.
		
		Positional arguments are treated as query components, combined using boolean AND reduction.
		
		Keyword arguments are processed depending on the passed in mapping and set of valid options, with non-
		option arguments treated as parametric query components, also ANDed with any positionally passed query
		components.
		
		Parametric querying with explicit `__eq` against these "reserved words" is possible to work around their
		reserved-ness.
		
		Querying options for find and aggregate may differ in use of under_score or camelCase formatting; this
		helper removes the distinction and allows either.

def _prepare_query(cls, mapping, valid, *args, **kw):
		"""Process arguments to query methods. For internal use only.
		
		Positional arguments are treated as query components, combined using boolean AND reduction.
		
		Keyword arguments are processed depending on the passed in mapping and set of valid options, with non-
		option arguments treated as parametric query components, also ANDed with any positionally passed query
		components.
		
		Parametric querying with explicit `__eq` against these "reserved words" is possible to work around their
		reserved-ness.
		
		Querying options for find and aggregate may differ in use of under_score or camelCase formatting; this
		helper removes the distinction and allows either.
		"""
		
		collection = cls.get_collection(kw.pop('source', None))
		query = Filter(document=cls, collection=collection)
		options = {}
		
		if args:
			query &= reduce(and_, args)
		
		# Gather any valid options.
		for key in tuple(kw):
			name = mapping.get(key, key)
			
			if name in valid:
				options[name] = kw.pop(key)
		
		# Support parametric projection via the use of iterables of strings in the form 'field' or '-field',
		# with name resolution. See the documentation for P for details.
		if 'projection' in options and not isinstance(options['projection'], Mapping):
			options['projection'] = P(cls, *options['projection'])
		
		# Support parametric sorting via the use of iterables of strings. See the documentation for S for details.
		if 'sort' in options:
			options['sort'] = S(cls, *options['sort'])
		
		if kw:  # Remainder are parametric query fragments.
			query &= F(cls, **kw)
		
		return cls, collection, query, options