ParentByName finds first parent recursively up hierarchy that matches the given name. It returns nil if not found.
(name string)
| 175 | // ParentByName finds first parent recursively up hierarchy that matches |
| 176 | // the given name. It returns nil if not found. |
| 177 | func (n *NodeBase) ParentByName(name string) Node { |
| 178 | if IsRoot(n) { |
| 179 | return nil |
| 180 | } |
| 181 | if n.Parent.AsTree().Name == name { |
| 182 | return n.Parent |
| 183 | } |
| 184 | return n.Parent.AsTree().ParentByName(name) |
| 185 | } |
| 186 | |
| 187 | // Children: |
| 188 |