<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def parent(self):
 """ Return the parent device. """

        if self._has_parent is None:
            _parent = self._ctx.backend.get_parent(self._ctx.dev)
            self._has_parent = _parent is not None
            if self._has_parent:
                self._parent = Device(_parent, self._ctx.backend)
            else:
                self._parent = None
        return self._parent