def METHOD_NAME(self, node):
    if node in self.memo:
        return self.repeated_node_visit(node)
    else:
        self.memo[node] = None
    for cls in node.__class__.__mro__:
        method = 'visit_' + cls.__name__
        visitor = getattr(self, method, None)
        if visitor is not None:
            break
    else:
        visitor = self.generic_visit
    result = visitor(node)
    self.memo[node] = result
    return result