Returns true if prospectiveChild
can be legally added to parent
.
False is returned if:
parent
and prospectiveChild
are equalparent
already contains prospectiveChild
prospectiveChild
has parent
as its own childIterates over children of root
, depth-first.
Applies predicate
to root
and all its child nodes, returning the node where
predicate
yields true.
Use findByValue to find a node by its value
Descends parent
, breadth-first, looking for a particular value.
Returns undefined if not found.
Applies predicate
to root
and all its child nodes, returning the node value for
predicate
yields true.
Use find to filter by nodes rather than values
Searches breadth-first for possibleValue
under and including parent
.
maxDepth
sets he maximum level to which the tree is searched.
Search through children in a path-like manner.
Returns true if possibleChild is contained within parent tree. That is, it is any sub-child.
Returns true if child
is parented at any level (grand-parented etc) by possibleParent
Returns true if possibleChild is contained within maxDepth children of parent node. By default only looks at immediate children (maxDepth = 0).
Returns true if child
exists within possibleParent
. By default it only looks at the immediate
parent (maxDepth: 0). Use Number.MAX_SAFE_INTEGER for searching recursively upwards (or hasAnyParent)
Checks if a child node has a parent with a certain value Note: by default only checks immediate parent. Set maxDepth to a large value to recurse
Iterates over parents of node
, starting with immediate parent
Iterates over siblings of node
.
Iterates over the children of
root
, breadth-first