'Get the parent of the model instance.
Returns:
Parent of contained entity or parent provided in constructor, None if
instance has no parent.'

def parent(self):

    if (self._parent is None):
        parent_key = self.parent_key()
        if (parent_key is not None):
            self._parent = get(parent_key)
    return self._parent
