isInTreeOf return false when visually nodes are connected

Hi!

I bumped into a situation which I cant understand.
I’m using node.isInTreeOf(node) method and it returns unexpected result
Visiually everything seems to be ok, but somehow node 2 (check screenshot) is not in the tree of Root node.
I’m trying to understand how that happened but right now I dont have any clues

Any ideas?

Thanks
Vlad

Can you confirm that node2 instanceof go.Node is true?
Is node2.isInTreeOf(node1) true?
Are there any Groups involved?

node2.isInTreeOf(node1) //false
node2 instanceof go.Node //true

No, in this case there is no go.Group involved

Let link12 be the Link between node1 and node2.
Is this true?

link12.fromNode === node1 &&
link12.toNode === node2 &&
link12.isTreeLink &&
link12.diagram.isTreePathToChildren

link12.fromNode === node1 &&
link12.toNode === node2 &&
link12.isTreeLink &&
link12.diagram.isTreePathToChildren

returns true

Which of these are true?

new go.Set(node1.linksConnected).has(link12)
new go.Set(node2.linksConnected).has(link12)
node2.findTreeParentLink() === link12
node2.findTreeParentNode() === node1
new go.Set(node1.findTreeChildrenLinks()).has(link12)
new go.Set(node1.findTreeChildrenNodes()).has(node2)

new go.Set(node1.linksConnected).has(link12) // true
new go.Set(node2.linksConnected).has(link12) // true
node2.findTreeParentLink() === link12 // false
node2.findTreeParentNode() === node1 // false
new go.Set(node1.findTreeChildrenLinks()).has(link12) // true
new go.Set(node1.findTreeChildrenNodes()).has(node2) // true

I think I know now why that happened, node2 has another link into it. Its hidden.
How I can escape from this use case? I want rootNode to be a tree root of this node2

Yes, they should all have been true.

Make any other Links coming into node2, or any extra links into any node, have Link.isTreeLink set or bound to false.

got it, I’ll try, thanks.