def as_dict(self):
        """
        Return the dependencies as a dictionary.

        Returns:
            dict: dictionary of dependencies.
        """
        return {
            'name': str(self),
            'modules': [m.as_dict() for m in self.modules],
            'packages': [p.as_dict() for p in self.packages]
        }