'Sets an ancestor for this query.
This restricts the query to only return results that descend from
a given model instance. In other words, all of the results will
have the ancestor as their parent, or parent\'s parent, etc.  The
ancestor itself is also a possible result!
Args:
ancestor: Model or Key (that has already been saved)
Returns:
Self to support method chaining.
Raises:
TypeError if the argument isn\'t a Key or Model; NotSavedError
if it is, but isn\'t saved yet.'

def ancestor(self, ancestor):

    if isinstance(ancestor, datastore.Key):
        if ancestor.has_id_or_name():
            self.__ancestor = ancestor
        else:
            raise NotSavedError()
    elif isinstance(ancestor, Model):
        if ancestor.has_key():
            self.__ancestor = ancestor.key()
        else:
            raise NotSavedError()
    else:
        raise TypeError('ancestor    should    be    Key    or    Model')
    return self
