Created function to extract representative trees based on predictions