itacart.serialization.tree_blob.is_ancestor_binary
- itacart.serialization.tree_blob.is_ancestor_binary(parent_node, child)[source]
Test ancestry directly on encoded nodes.
Avoids decoding, which matters when the check runs inside a smart contract or a tight indexing loop.
When
childis a tree blob the relation is quantified over every leaf: an ancestor of a tree prefixes the whole tree, not merely some branch of it. A parent covering one leaf of a two-leaf tree is not an ancestor of that tree.- Parameters:
- Return type:
- Returns:
Trueif the ancestry relation holds for every leaf given.- Raises:
MalformedBlobError – If either operand is malformed.
Example
>>> is_ancestor_binary( ... encode_node("NE(0625/0451)"), encode_node("NE(0625/0451(3))") ... ) True