MCPcopy Create free account
hub / github.com/cogentcore/core / ParentByName

Method ParentByName

tree/nodebase.go:177–185  ·  view source on GitHub ↗

ParentByName finds first parent recursively up hierarchy that matches the given name. It returns nil if not found.

(name string)

Source from the content-addressed store, hash-verified

175// ParentByName finds first parent recursively up hierarchy that matches
176// the given name. It returns nil if not found.
177func (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

Callers

nothing calls this directly

Calls 2

IsRootFunction · 0.85
AsTreeMethod · 0.65

Tested by

no test coverage detected