Common Widgets Logic

Hi all.
I have one widget that is used in the main menu and in the game menu.
These 2 menus are different, but they both have a link to a common widget.

I have this problem: If I make a blueprint script for a common widget, then the logic as a whole will break for the entire menu.
For example: I have a main menu, and in the menu there is a settings button that leads to the settings page, on the settings page itself there is a “Back” button that should return back to the main menu. I also have a game menu where there is also a settings button, but if I go to the settings and press “back”, then I will be transferred from the game to the main menu.

Please help with advice on how to implement a check for widgets so as not to duplicate widgets

IF I UNDERSTAND CORRECTLY, YOU CAN USE A WIDGET SWITCHER AND PLACE THE MENUS INSIDE IT AND IN YOUR “SHELL WIDGET” YOU WILL JUST NEED TO CHANGE THE INDEX OF THE CURRENT MENU