def _get_calling_module_and_class():
    this_module = sys.modules[__name__]
    this_package = this_module.__package__
    frame = sys._getframe() # frame = inspect.currentframe()
    try:
        while frame is not None:
            # try and avoid calling inspect.getmodule as it confuses the callstack
            # to break out of cython when evaluating nodes
            module = None
            if hasattr(frame, "__module__"):
                module = sys.modules.get(frame.__module__)
            else:
                # look for the module by filename
                filename = frame.f_code.co_filename
                if filename:
                    file_base, ext = os.path.splitext(filename)
                    for m in sys.modules.values():
                        if hasattr(m, "__file__"):
                            # ignore the .py/.pyc suffixes
                            m_base, ext = os.path.splitext(m.__file__)
                            if m_base == file_base:
                                module = m
                                break
            if getattr(module, "__package__", None) != this_package:
                clsname = frame.f_code.co_name
                if clsname == "<module>":
                    clsname = None
                return module, clsname
            frame = frame.f_back
    finally:
        # be careful not to create reference cycles
        # cypthon doesn't support deletion of local c variables,
        # but assigning it to None will have the same effect
        #del frame
        frame = None

    return None, None
returns the first module on the call stack that's not this module
dataset/ETHPy150Open manahl/mdf/mdf/nodes.py/_get_calling_module_and_class