int
tree_ruleHead_third(TreeHist* treeh)
{
    InputTree* specTree = NULL;
    if(Feature::isLM) specTree = tree_ruleTree(treeh, 2);
    if(specTree) return headFromParTree(treeh->tree);
    InputTree* trdtree = tree_ruleTree(treeh,3);
    if(!trdtree) return nullWordInt;
    else return headFromTree(trdtree);
}
int
tree_ruleHead_third(FullHist* treeh)
{
  Val* specTree = NULL;
  if(Feature::isLM) specTree = tree_ruleTree(treeh, 2);
  if(specTree)
    {
      FullHist* pt = treeh->back;
      if(!pt) return nullWordInt;
      int ans = pt->hd->toInt();
      return ans;
    }
  Val* trdtree = tree_ruleTree(treeh,3);
  if(!trdtree) return nullWordInt;
  else return trdtree->wrd();
}
int
tree_parent_head(TreeHist* treeh)
{
    InputTree* specTree = NULL;
    if(Feature::isLM) specTree = tree_ruleTree(treeh,2);
    if(specTree) return headFromTree(specTree);
    else return headFromParTree(treeh->tree);
}
int
fh_parent_head(FullHist* tree)
{
  Val* spectree = NULL;
  if(Feature::isLM) spectree = tree_ruleTree(tree, 2);
  if(spectree)
    {
      //cerr << "found  st " << endl;
      return spectree->wrd();
    }
  FullHist* pt = tree->back;
  if(!pt) return nullWordInt;
  int ans = pt->hd->toInt();
  assert(ans >= -1);
  return ans;
}