Add recursive truncate function