Add isNodeValid function.