code: function existing_stats(stats_type, bucket){
    matches = [];
  
    //typical case: one-off, fully qualified
    if (bucket in stats_type) {
      matches.push(bucket);
    }
  
    //special case: match a whole 'folder' (and subfolders) of stats
    if (bucket.slice(-2) == ".*") {
      var folder = bucket.slice(0,-1);
  
      for (var name in stats_type) {
        //check if stat is in bucket, ie~ name starts with folder
        if (name.substring(0, folder.length) == folder) {
          matches.push(name);
        }
      }
    }
  
    return matches;
  }
docs: existing_stats - find fully qualified matches for the requested stats bucket
  
  @param stats_type array of all statistics of this type (eg~ timers) to match
  @param bucket string to search on, which can be fully qualified,
  or end in a .* to search for a folder, like stats.temp.*
  
  @return array of fully qualified stats that match the specified bucket. if
  no matches, an empty array is a valid response