
Preheat the oven to 350°F. Butter a 13-by-9-inch baking dish and add the hash browns, spreading them into an even layer.
In a large bowl, combine the shredded mozzarella, milk, half-and-half, pesto, eggs, green onions, and some salt and pepper. Pour the mixture over the hash browns and top with the cherry tomatoes and mozzarella pearls.
Cover with foil, and bake for 30 minutes. Remove the foil, and continue baking until the center is set and edges are bubbly, 30 to 35 minutes.
Let the casserole rest for a few minutes before cutting into squares. Sprinkle with the basil leaves, if using, and serve.