def tree_replace_function(self, dst, func_node):
        if isinstance(func_node.children[0], Leaf) and \
           func_node.children[0].value == 'def' and \
           isinstance(func_node.children[1], Leaf):
            func_name = func_node.children[1].value
        else:
            raise self.TranslationError(
                func_node % "Cannot replace function %r"
            )
        for child in dst.children:
            if isinstance(child, Node) and \
               type_repr(child.type) == 'funcdef':
                if isinstance(child.children[0], Leaf) and \
                   child.children[0].value == 'def' and \
                   isinstance(func_node.children[1], Leaf) and \
                   child.children[1].value == func_name:
                    child.children = func_node.children
                    child.changed()
                    return
        # Next two lines will append a function if it's not found,
        # but that's different behavior then in the other translator
        #dst.append_child(func_node)
        #return
        raise self.TranslationError(
            "Cannot find function %r for replace" % func_name
        )
dataset/ETHPy150Open anandology/pyjamas/pyjs/src/pyjs/translator_dict.py/Translator.tree_replace_function/swapped operands of `%`