<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def iflat_nodes(self, status=None, op="==", nids=None):
 """ Generators that produces a flat sequence of nodes. if status is not None, only the tasks with the specified status are selected. nids is an optional list of node identifiers used to filter the nodes. """

        nids = as_set(nids)

        if status is None:
            if not (nids and self.node_id not in nids):
                yield self

            for work in self:
                if nids and work.node_id not in nids: continue
                yield work
                for task in work:
                    if nids and task.node_id not in nids: continue
                    yield task
        else:
            # Get the operator from the string.
            op = operator_from_str(op)

            # Accept Task.S_FLAG or string.
            status = Status.as_status(status)

            if not (nids and self.node_id not in nids):
                if op(self.status, status): yield self

            for wi, work in enumerate(self):
                if nids and work.node_id not in nids: continue
                if op(work.status, status): yield work

                for ti, task in enumerate(work):
                    if nids and task.node_id not in nids: continue
                    if op(task.status, status): yield task