<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def prune(self, root):
 """Prune stale cache files If the option --cache-target-max-entry is greater than zero, then prune will remove all but n old cache files for each target/task. :param str root: The path under which cacheable artifacts will be cleaned """


    max_entries_per_target = self._max_entries_per_target
    if os.path.isdir(root) and max_entries_per_target:
      safe_rm_oldest_items_in_dir(root, max_entries_per_target)