<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def where(self, q=None, where_type='AND', **kwargs):
 """ Adds a where condition as a Q object to the query's ``Where`` instance. :type q: :class:`Q <django:django.db.models.Q>` :param q: A django ``Q`` instance. This will be added to the query's ``Where`` object. If no Q object is passed, the kwargs will be examined for params to be added to Q objects :param where_type: str :param where_type: The connection type of the where condition ('AND', 'OR') :return: self :rtype: :class:`Query <querybuilder.query.Query>` """

        # self.mark_dirty()
        if q is not None:
            self._where.wheres.add(q, where_type)
        if len(kwargs):
            for key, value in kwargs.items():
                q = Q(**{
                    key: value
                })
                self._where.wheres.add(q, where_type)
        return self