code: def _build_item_closure(itemset, productionset):
      
      #For every item inside current itemset, if we have the following rule:
      #  xxx <cursor><nonterminalSymbol> xxx  append every rule from self._productionruleset that begins with that NonTerminalSymbol
      if not isinstance(itemset, LR0ItemSet):
          raise TypeError
      import copy
      resultset = copy.copy(itemset)
      changed = True
      while changed:
          changed = False
          for currentitem in resultset.itemlist:
              nextsymbol = currentitem.next_symbol()
              if nextsymbol is None:
                  break
              for rule in productionset.productions:
                  newitem = LR0Item(rule)
                  if rule.leftside[0] == nextsymbol and newitem not in resultset.itemlist:
                      resultset.append_item(newitem)
                      changed = True
      return resultset
docs: Build input itemset closure