code: def validate_program(self):
          
          terminals = [0]
          for node in self.program:
              if isinstance(node, _Function):
                  terminals.append(node.arity)
              else:
                  terminals[-1] -= 1
                  while terminals[-1] == 0:
                      terminals.pop()
                      terminals[-1] -= 1
          return terminals == [-1]
docs: Rough check that the embedded program in the object is valid.