def METHOD_NAME(self, *args, **kwargs):
    def finalize_submodules():
        for name, submodule in self._submodules:
            if not hasattr(submodule, "finalize"):
                continue
            if submodule.finalized:
                continue
            submodule.METHOD_NAME(*args, **kwargs)
    if not self.finalized:
        self.finalized = True
        finalize_submodules()
        self.do_finalize(*args, **kwargs)
        finalize_submodules()
        for name, submodule in self._submodules:
            self._module._add_submodule(submodule, name)