To achieve that result, you could use the is_visible() method, which is a method common to all canvas items.
So, the condition you wish to write might look like this:
Obviosuly you have to substitue "my_dialog" with your dialog node.
To know more about what is possible to do with canvasItems such as PopupDialogs, you could read the documentation. It is well written and quite easy to understand.
Here are the links: