human
I wrote the below code

    def visit_all(tree, visitor):
        visitor(tree)
        for node in tree.values():
            visit_all(node, visitor)
    states = []
    visit_all(tree, states.append)
    next_state_id = len(states)
    transitions = {}
    chars_by_state = {}
    new_eq_classes = set()
    for state in states:
        chars = chars_by_state[state] = set()
        for (char, target) in state.items():
            if ignore_case:
                char = char.lower()
            transitions[(state, char)] = set([target])
            chars.add(char)
        for (char, target) in tree.items():
            if ignore_case:
                char = char.lower()
            chars.add(char)
            key = (state, char)
            if (key in transitions):
                transitions[key].add(target)
                new_eq_classes.add(key)
            else:
                transitions[key] = set([target])
    existing_eq_classes = {}
    eq_classes_by_state = {}
    while new_eq_classes:
        eq_classes = new_eq_classes
        new_eq_classes = set()
        for key in eq_classes:
            eq_states = transitions[key]
            if (len(eq_states) < 2):
                continue
            eq_key = tuple(sorted([s.id for s in eq_states]))
            if (eq_key in existing_eq_classes):
                transitions[key] = set([existing_eq_classes[eq_key]])
                continue
            new_state = NfaState(next_state_id)
            matches = []
            for s in eq_states:
                matches.extend(s.matches)
            matches.sort(key=len, reverse=True)
            new_state.matches = matches
            eq_classes_by_state[new_state] = eq_states
            existing_eq_classes[eq_key] = new_state
            next_state_id += 1
            transitions[key] = set([new_state])
            new_chars = chars_by_state[new_state] = set()
            for state in eq_states:
                chars = chars_by_state[state]
                new_chars.update(chars)
                for char in chars:
               ...

What's a good function header?
assistant
#Here's a good function header.

def nfa2dfa(tree, ignore_case):