Skip to content

Commit

Permalink
NEW: method to check direct relation to ancestor
Browse files Browse the repository at this point in the history
  • Loading branch information
nnako committed Jun 13, 2023
1 parent 3453f19 commit ffb6d3e
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/freeplane.py
Original file line number Diff line number Diff line change
Expand Up @@ -1883,6 +1883,38 @@ def get_indexchain_until(self, node):
# reverse results
return list(reversed(lstIdxValues))


def is_descendant_of(self, node):
"""
determine if the current node object has a direct relational connection
to a given node element. so, if the current node object is a child,
grand-child, ... of that given node element.
"""

# walk up the parent elements until the given element is found or the
# search ends with the root node

# get 1st parent element
parent = self.parent

# loop
while parent:

# check for match
if parent.id == node.id:
return True

# leave function if we reached the root node
if parent.id == self._map.rootnode:
return False

# get next parent further up
parent = parent.parent

# this statement shouldn't be reached
return False


@property
def is_rootnode(self):
if self._map._rootnode == self._node \
Expand Down

0 comments on commit ffb6d3e

Please sign in to comment.