code: def _unit(g):
      
      nt_unit_rule = get_any_nt_unit_rule(g)
      while nt_unit_rule:
          g = _remove_unit_rule(g, nt_unit_rule)
          nt_unit_rule = get_any_nt_unit_rule(g)
      return g
docs: Applies the UNIT rule to 'g' (see top comment).