let rec apply_labels p = function 
  | [] -> p | label::labels -> Pnamed(label,apply_labels p labels)