MCPcopy Create free account
hub / github.com/VectifyAI/PageIndex / is_leaf_node

Function is_leaf_node

pageindex/utils.py:191–215  ·  view source on GitHub ↗
(data, node_id)

Source from the content-addressed store, hash-verified

189 return leaf_nodes
190
191def is_leaf_node(data, node_id):
192 # Helper function to find the node by its node_id
193 def find_node(data, node_id):
194 if isinstance(data, dict):
195 if data.get('node_id') == node_id:
196 return data
197 for key in data.keys():
198 if 'nodes' in key:
199 result = find_node(data[key], node_id)
200 if result:
201 return result
202 elif isinstance(data, list):
203 for item in data:
204 result = find_node(item, node_id)
205 if result:
206 return result
207 return None
208
209 # Find the node with the given node_id
210 node = find_node(data, node_id)
211
212 # Check if the node is a leaf node
213 if node and not node.get('nodes'):
214 return True
215 return False
216
217def get_last_node(structure):
218 return structure[-1]

Callers

nothing calls this directly

Calls 1

find_nodeFunction · 0.85

Tested by

no test coverage detected