Better recursive apply function for filters and formatters