如何在GOJS中获取树的所有树叶节点

How to get all Tree Leaf nodes of tree in GOJS

我要获取所有树叶节点

下面的代码是我用来获取的,但是没有用

myDiagram.findNodesByExample({ isTreeLeaf:true }).each(function (n) { 
    myDiagram.findNodeForKey(n.data.parent).collapseTree(); 
});

Note: I don't have property isTreeLeaf in my node data. I want it from node property

有没有简单的获取叶节点的方法?

myDiagram.nodes.filter(n => n.isTreeLeaf).each(n => console.log(n.key));