If the Button False event is called before the widget is created, it will remove the widget from viewport. But it is not created yet, so it accesses none.
Same goes for the branch, it checks if the widget is in viewport, but accesses none.
You would probably want to use a is valid check to see if it is valid.
Though to be honest, the way I would do it is to create the widget elsewhere and store a reference of it, which you check if it is in viewport like you are doing now.