code: def labelset_heads(self, label):
          
          _eps = self._eps
          _vars = self._vars
          _hcons = self._hcons
          nodeids = {nodeid: _eps[nodeid][3].get(IVARG_ROLE, None)
                  for nodeid in _vars[label]['refs']['LBL']}
          if len(nodeids) <= 1:
              return list(nodeids)
  
          scope_sets = {}
          for nid in nodeids:
              scope_sets[nid] = _ivs_in_scope(nid, _eps, _vars, _hcons)
  
          out = {}
          for n in nodeids:
              out[n] = 0
              for role, val in _eps[n][3].items():
                  if role == IVARG_ROLE or role == CONSTARG_ROLE:
                      continue
                  elif any(val in s for n2, s in scope_sets.items() if n2 != n):
                      out[n] += 1
  
          candidates = [n for n, out_deg in out.items() if out_deg == 0]
          rank = {}
          for n in candidates:
              iv = nodeids[n]
              pred = _eps[n][1]
              if iv in _vars and self.nodeid(iv, quantifier=True) is not None:
                  rank[n] = 0
              elif pred.is_quantifier():
                  rank[n] = 0
              elif pred.type == Pred.ABSTRACT:
                  rank[n] = 2
              else:
                  rank[n] = 1
  
          return sorted(candidates, key=lambda n: rank[n])
docs: Return the heads of the labelset selected by *label*.
  
          Args:
              label: the label from which to find head nodes/EPs.
          Returns:
              An iterable of nodeids.