<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _sitelist(self, matrix):
 """ Returns a list of sites from a SiteMatrix, optionally filtered by 'domain' param """

        _list = []
        for item in matrix:
            sites = []

            if isinstance(matrix[item], list):
                sites = matrix[item]
            elif isinstance(matrix[item], dict):
                sites = matrix[item]['site']

            for site in sites:
                if len(site.keys()) > 4:  # closed, fishbowl, private
                    continue
                domain = self.params.get('domain')
                if domain:
                    if domain in site['url']:
                        _list.append(site['url'])
                else:
                    _list.append(site['url'])

        return _list