added an optional parameter so that the items to be cached can be specified if needed, else it defaults to the tree