Check for the existence of a node before inserting a new one