Add a check for a repeating loop that can occur when the same term is found to be a solution for the current node and child node.
Add a check for a repeating loop that can occur when the same term is found to be a solution for the current node and child node.