<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def collect(self, *keys, **kwargs):
 """Generator function traversing tree structure to collect values of a specified key. :param keys: the keys to look for in the report :type key: str :keyword recursive: look for key in children nodes :type recursive: bool :keyword with_path: whether the yield values is a tuple of 2 elements containing report-path and the value or simply the value. :type with_path: bool :rtype: generator providing either values or tuples of 2 elements containing report path and value depending on with_path parameter """

        if not keys:
            raise Exception('Missing key')
        has_values = functools.reduce(
            operator.__and__, [key in self.data for key in keys], True
        )
        if has_values:
            values = tuple([self.data[key] for key in keys])
            if len(values) == 1:
                values = values[0]
            if kwargs.get('with_path', False):
                yield self.path, values
            else:
                yield values
        if kwargs.get('recursive', True):
            for child in self.children.values():
                for value in child.collect(*keys, **kwargs):
                    yield value