When a scene is instanced from a file, its topmost node contains the filename from which it was loaded.
So one of the ways would be:
if not p_node.filename.empty():
It doesn't answer whether a node is an instance of a particular scene, though. See other answers.