def next_state(self, rule=None):
num_kids = self.current_node.children.count()<EOL>next_node = None<EOL>if num_kids == <NUM_LIT:0>:<EOL><INDENT>raise AttributeError('<STR_LIT>' % (<EOL>self.flow.id))<EOL><DEDENT>elif num_kids == <NUM_LIT:1>:<EOL><INDENT>next_node = self.current_node.children.first()<EOL><DEDENT>else:<EOL><INDENT>if not rule:<EOL><INDENT>raise AttributeError(('<STR_LIT>'<EOL>'<STR_LIT>') % self.current_node.data.rule_name)<EOL><DEDENT>for node in self.current_node.children.all():<EOL><INDENT>if node.data.rule_label == rule.class_label:<EOL><INDENT>next_node = node<EOL>break<EOL><DEDENT><DEDENT>if not next_node:<EOL><INDENT>raise AttributeError(('<STR_LIT>'<EOL>'<STR_LIT>') % (<EOL>self.current_node.data.rule_name))<EOL><DEDENT><DEDENT>self.current_node.data.rule.on_leave(self)<EOL>next_node.data.rule.on_enter(self)<EOL>self.current_node = next_node<EOL>self.save()<EOL>
Proceeds to the next step in the flow.  Calls the associated
        :func:`Rule.on_leave` method for the for the current rule and the
        :func:`Rule.on_enter` for the rule being entered.  If the current step
        in the flow is multipath then a valid :class:`Rule` subclass must be
        passed into this call.  

        If there is only one possible path in the flow and a :class:`Rule` is
        given it will be ignored.

        :param rule: 
            if the current :class:`Rule` in the :class:`Flow` is multipath
            then the next :class:`Rule` in the flow must be provided.