ParentLevel finds a given potential parent node recursively up the hierarchy, returning the level above the current node that the parent was found, and -1 if not found.
(parent Node)
| 159 | // hierarchy, returning the level above the current node that the parent was |
| 160 | // found, and -1 if not found. |
| 161 | func (n *NodeBase) ParentLevel(parent Node) int { |
| 162 | parLev := -1 |
| 163 | level := 0 |
| 164 | n.WalkUpParent(func(k Node) bool { |
| 165 | if k == parent { |
| 166 | parLev = level |
| 167 | return Break |
| 168 | } |
| 169 | level++ |
| 170 | return Continue |
| 171 | }) |
| 172 | return parLev |
| 173 | } |
| 174 | |
| 175 | // ParentByName finds first parent recursively up hierarchy that matches |
| 176 | // the given name. It returns nil if not found. |
no test coverage detected