Returns the module that this code element belongs to.

def module(self):
        """Returns the module that this code element belongs to."""
        if self._module is None:
            root = self
            while self._module is None and root is not None:
                if isinstance(root, Module):
                    self._module = root
                else:
                    root = root.parent

        return self._module