| 191 | def 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) |