class_docstr: Models a node within a search space.
  
  Nodes can be internal or terminal, and may or may not be choices.
  A choice is a node that models a discrete choice out of k > 1 options.
class_docstr_tok: ["Models","a","node","within","a","search","space",".","Nodes","can","be","internal","or","terminal",",","and","may","or","may","not","be","choices",".","A","choice","is","a","node","that","models","a","discrete","choice","out","of","k",">","1","options","."]
docstr: Iterates over this node.
  
  If the node is terminal, yields the key and value.
  Otherwise, first yields all values and then iterates over the values.
docstr_tok: ["Iterates","over","this","node",".","If","the","node","is","terminal",",","yields","the","key","and","value",".","Otherwise",",","first","yields","all","values","and","then","iterates","over","the","values","."]
code: def __iter__(self):
      """Iterates over this node.
  
      If the node is terminal, yields the key and value.
      Otherwise, first yields all values and then iterates over the values.
  
      """
      if self.terminal:
          yield self.key, self.value
      else:
          value = list(itertools.chain(*self.value))
  
          if any([not x.terminal or x.choice for x in self.value]):
              value.insert(
                  0, ([], Options([node.key for node in self.value]))
              )
  
          for k, v in value:
              if type(k) is list:
                  key = [self.key] + k
              else:
                  key = [self.key, k]
              yield key, v
  
imports: import functools
  import itertools
  import collections
  import math
label_desc: Use image node_id 6 for calling the Node obj's underlying member method code with example usage: obj.__iter__() without return types