revamp addheader to process whole trees instead of single files