@@ -919,6 +919,36 @@ def matchNodeToNode(self, node, nodeOther):
919919 else :
920920 # Assume nonmatching
921921 return False
922+
923+ def matchNodeToChild (self , parentNode , childNode ):
924+ """
925+ Return `True` if `parentNode` is a parent of `childNode`. Otherwise, return `False`.
926+ Both `parentNode` and `childNode` must be Entry types with items containing Group or LogicNode types.
927+ If `parentNode` and `childNode` are identical, the function will also return `False`.
928+ """
929+
930+ if isinstance (parentNode .item , Group ) and isinstance (childNode .item , Group ):
931+ if self .matchNodeToStructure (parentNode ,childNode .item , atoms = childNode .item .getLabeledAtoms ()) is True :
932+ if self .matchNodeToStructure (childNode ,parentNode .item , atoms = parentNode .item .getLabeledAtoms ()) is False :
933+ return True
934+ return False
935+
936+ elif isinstance (parentNode .item ,LogicOr ) and isinstance (childNode .item ,Group ):
937+ if self .matchNodeToStructure (parentNode ,childNode .item , atoms = childNode .item .getLabeledAtoms ()) is True :
938+ return True
939+ else :
940+ return False
941+ elif isinstance (parentNode .item ,LogicOr ) and isinstance (childNode .item ,LogicOr ):
942+ if parentNode .item .matchToLogicOr (childNode .item ):
943+ # the two LogicOrs are identical
944+ return False
945+ else :
946+ for group in parentNode .item .components :
947+ if group not in childNode .item .components :
948+ return False
949+ return True
950+ else :
951+ return False
922952
923953 def matchNodeToStructure (self , node , structure , atoms ):
924954 """
0 commit comments