appendHistory hist he =
    case (he, hs_entry hist) of
      (HistoryRun hetid _, HistoryRun histtid _) 
          | hetid == histtid ->
              appendHistory (hs_parent hist) he
      (HistoryAdvanceLog _, HistoryAdvanceLog _)
          | he == hs_entry hist -> hist
      _ -> mkSimpleHistory hist he
appendHistory hist he =
    case (he, hs_entry hist) of
      (HistoryRun hetid _, HistoryRun histtid _) 
          | hetid == histtid ->
              appendHistory (hs_parent hist) he
      (HistoryAdvanceLog _, HistoryAdvanceLog _)
          | he == hs_entry hist -> hist
      _ -> mkSimpleHistory hist he
appendHistory hist he =
    case (he, hs_entry hist) of
      (HistoryRun hetid _, HistoryRun histtid _) 
          | hetid == histtid ->
              appendHistory (hs_parent hist) he
      (HistoryAdvanceLog _, HistoryAdvanceLog _)
          | he == hs_entry hist -> hist
      _ -> mkSimpleHistory hist he