Why do you need to stash the items for node.chef_environment in a different place than _wildcard?
Shouldn't  you just stash whichever one you actually found? Just put _wildcard item under encrypted_data_bags[key]

You should really only memoize pure functions.

The was this is written we can get 2 different data bags back if it initially returns _wildcard, then we save an item for the environment and then call this again.