Getting Error when try to select key from diagram using Selenium

I am trying to select key from diagram using Javascript and Selenium webdriver but getting error :

unknown error: Cannot read property ‘findNodeForKey’ of undefined

My Code :

if (Base.getdriver() instanceof JavascriptExecutor) {
	  String code = "var key = myTmGo.Diagram.model.nodeDataArray[1]"; 
	  ((JavascriptExecutor) Base.getdriver()).executeScript("var node = myTmGo.Diagram.findNodeForKey(key);"+
	  ((JavascriptExecutor) Base.getdriver()).executeScript(code);


myTmGo.Diagram must be undefined if myTmGo.Diagram.findNodeForKey(key); evaluates in such an error.

In general we cannot debug your JavaScript code for you, we can only help with GoJS issues.