IsAncestorOf returns whether this node is an ancestor of the specified node. Returns true if they are the same.
(desc INode)
| 376 | |
| 377 | // IsAncestorOf returns whether this node is an ancestor of the specified node. Returns true if they are the same. |
| 378 | func (n *Node) IsAncestorOf(desc INode) bool { |
| 379 | |
| 380 | if desc == nil { |
| 381 | return false |
| 382 | } |
| 383 | if n == desc.GetNode() { |
| 384 | return true |
| 385 | } |
| 386 | for _, child := range n.Children() { |
| 387 | res := child.IsAncestorOf(desc) |
| 388 | if res { |
| 389 | return res |
| 390 | } |
| 391 | } |
| 392 | return false |
| 393 | } |
| 394 | |
| 395 | // LowestCommonAncestor returns the common ancestor of this node and the specified node if any. |
| 396 | func (n *Node) LowestCommonAncestor(other INode) INode { |
nothing calls this directly
no test coverage detected