Hi Scott,
Perhaps combining the listener that @pekkaklarck mentioned with --dryrun might get you what you want?
Otherwise if you want to do it in code, you probably need a self recursive function that iterates in a for loop over the identified keywords and then resolves the keywords in them, then calls itself with each keyword, but that could potentially get quite slow for the user.
Dave.