def node_frame_class(
    node: astroid.node_classes.NodeNG
) -> Optional[astroid.node_classes.NodeNG]:
    """return klass node for a method node (or a staticmethod or a
    classmethod), return null otherwise
    """
    klass = node.frame()

    while klass is not None and not isinstance(klass, astroid.ClassDef):
        if klass.parent is None:
            klass = None
        else:
            klass = klass.parent.frame()

    return klass
return klass node for a method node (or a staticmethod or a
    classmethod), return null otherwise