'Add a stage task, popping from own queue and appending to the queue
of the next node'

def add_stage(self, prefix, node, next):

    f = node.target
    name = ('%s_%s' % (prefix, node.name))
    if next:
        next_name = ('%s_%s' % (prefix, next.name))
    def inner(*args, **kwargs):
        out = f(*args, **kwargs)
        if ((out is not None) and next):
            self._enqueue(next_name, out)
        return out
    task = functools.wraps(f)(inner)
    self.tasks[name] = task
