Forty years ago, the great tropical ecologist Dan Janzen noticed something funny about the plants in Costa Rica. Many species invested a lot of their energy in producing huge fruits with tough seeds and seed pods, which no animals seemed to eat. With nothing to consume them, the seeds and pods just fell to the jungle floor and rotted, or died in the shade of their parent trees.

In a now legendary paper cowritten with Paul S. Martin (“Neotropical Anachronisms: The Fruits the Gomphotheres Ate”), Janzen speculated that there was a good reason for this: The jungle plants’ original partners had all gone extinct. They identified a long list of plants, such as the jicaro and guanacaste in South America and honey locust, pawpaw, persimmon, and Osage orange in North America, which seem to have lost their original dispersal agents. These species had evolved over millions of years to have their seeds eaten and spread around by ground sloths, glyptodonts, gomphotheres, (a family of mastodon-like creatures from South America), extinct horses, and other vanished megafauna. The great extinctions at the end of the Pleistocene left these plants as orphans.

They’re not alone. In many ways, we all live in an orphaned world. Extinct megafauna like the mammoth and ground sloth weren’t just hapless prey or passive victims of climate change. They were engineers, actively shaping their environment to suit their needs. In doing so, they created evolutionary niches in which plants and predators could thrive. It’s these patterns of coevolution and mutual dependence that create a functioning ecosystem.

Since the Quaternary extinction event in which the world lost some 50 percent of its large mammal species, many crucial links in the food chain have gone missing. Figuring out exactly what this has done to the world we’re living in now is something paleoecologists have been trying to figure out for a good half-century. Like anything to do with ecology, the problem of how missing megafauna affect modern-day habitats is a complex puzzle, with multiple lines of evidence. First you have to figure out who ate what and where, in what season and in what quantity. And if you want to do that, the best place to look is ancient poop.

In the past few years, a group of researchers in New Zealand led by the paleoecologist Jamie Wood have succeeded in using ancient droppings to reconstruct the world of the giant moa, one of a group of large flightless birds that includes the ostrich, emu, cassowary, and Madagascar’s extinct elephant birds. From the fossil record, we know there were at least nine species of moa on New Zealand. The smallest, the little bush moa, stood a little over four feet tall. At 12 feet with its neck outstretched, the largest, the giant moa, may have been the tallest bird that ever lived. In between these two extremes, moas came in a range of sizes and forms, adapted for a range of habitats.

Before the arrival of human beings, New Zealand was a paradise of birds. When it started drifting away from its parent supercontinent of Gondwana some 85 million years ago, it only carried with it a few primitive mammals. In time, they went extinct, as did the dinosaurs. With 2,000 miles between it and the next nearest landmass, the only group that could repopulate New Zealand were the birds. Over millions of years, they evolved to occupy most of the available ecological niches (they were joined later by bats, who took the place mice occupy in most terrestrial ecosystems). Birds functioned as the only major predators and herbivores. They were New Zealand’s antelopes, cheetahs, and giraffes.

New Zealand’s plants evolved in concert with its birds. An unusual number of the islands’ bushes and trees have what’s called a divaricating pattern of growth. The branches of these plants grow at wildly offset angles, creating an impenetrable mesh of interwoven twigs. Growing this way costs a lot of energy—the plants lose precious sunlight by creating their own shade—but it makes for an effective defense against a large, toothless herbivore like the moa. But now, with the moa gone and replaced by mammalian herbivores (mostly sheep), they find themselves defenseless.

New Zealand is a perfect place to study the effects of megafauna on their landscape. For one, the megafauna stayed around until very recently. Giant moas were happily foraging for tree-fern buds while the Magna Carta was being signed and the Florentines were building Brunelleschi’s dome. Two, it was quite varied: Nine species of moa coexisted on the islands, each (presumably) with its own habits and ecological niche. And three, all those moas left a lot of poop. People have been finding it in caves since the 1870s. Natural-history museums have over 2000 specimens on file, from 30 localities, with more waiting to be discovered.

Woods’s lab used some of this abundant resource to settle a few mysteries about New Zealand’s lost ecosystems. Using a combination of ancient DNA, plant macrofossils, and pollen, his team reconstructed the diet of four moa species. They found that the heavy-footed moa preferred to graze in open fields and grasslands. The bush moa preferred to munch on forest understory. The giant moa was more of a generalist, moving between these two habitats at will.

Figuring out moa diet is only the tip of the dungheap when it comes to ancient poop studies. Prehistoric dung has a wealth of uses for science, from tracking the demise of the mammoth to deciphering the peopling of the Americas. The spores of Sporormiella, a type of mold that loves nothing better than a nice pat of dung to grow over, have been used as a proxy to track the abundance of megafauna across the millennia. Carbon dating DNA-fingerprinted coprolites from the Paisley Caves in Oregon helped prove the presence of pre-Clovis humans (and, as a bonus, testing feces for DNA doesn’t raise the same ethical quandaries as testing ancient skeletal remains).

The climate history of the American Southwest was established in large part thanks to a deposit of sloth dung discovered in Arizona in the 1950s. The dung was left by the Shasta ground sloth, a small species as ground sloths go, more bearlike than the more famous Megatherium, which grew to the size of an elephant. For around 30,000 years, these sloths used Rampart Cave, a hollow in the side of the Grand Canyon, as their latrine. Pollen in the accumulated droppings recorded the shifts in vegetation that accompanied the arrival and departure of past glacial maxima. Crucially, they proved that the shift in vegetation and temperature that came with the end of the last Ice Age wasn’t particularly new or extreme. It was something that had happened multiple times in previous millennia.

Tragically, the precious dung deposit caught fire in 1976. The National Park Service spent tens of thousands of dollars to save it, but to no avail. It made the nightly news. Walter Cronkite joked about “endangered feces,” but to Paul Martin, a geoscientist who devoted much of his career to reconstructing the environment of the ancient Southwest (and came up with the overkill hypothesis in the process) compared it to losing the Library of Alexandria.

Martin felt better a few years later, when two zoologists discovered an unusually big sphere of chewed-up grass in a cave in southern Utah. Subsequent visits turned up several more dung balls of surprising size, which radiocarbon dating showed to be about 12,000 years old. Martin guessed they came from America’s second-largest extinct mammal, the Columbian mammoth.

Larger than any living elephant, the Columbian mammoth, was, like them, a prodigious maker of dung. The Utah cave, named Bechan, from the Navajo word for “big shit,” showed just how prodigious. Excavations in the mid-’80s revealed a layer of dung 16 inches thick covering a surface of several tennis courts (that’s 14,000 cubic feet of dung total). This July, a team at McMaster University in Ontario reported that it had successfully sequenced DNA from the dung boluses, proving that they really did come from mammoths.

The most spectacular dung find of recent years comes from the Page-Ladson site on the Aucilla River in the Florida Panhandle. The site is a sinkhole in the middle of the Aucilla River, on one of the few stretches where it flows above ground, but it used to be a spring-fed pond. Fourteen thousand years ago, when Florida was much cooler and drier than it is today (and also much larger, thanks to lower sea levels), various animals would come to this pond to drink. That made it a great spot for visiting predators, including humans. Underwater excavations at Page-Ladson turned up clear signs of human activity, including mastodon butchery, making it the oldest confirmed habitation in the American Southeast.

But the Aucilla mastodons weren’t just sitting ducks for human hunters. Mostly, they used the pool as a wallow, the way elephants use drinking holes in Africa today. In the process, they left behind a heck of a lot of dung. At some point, the water level rose, burying the wallow in sediment, and preserving this priceless fecal Pompeii for posterity.

Archaeologists have found hundreds of cubic meters of mastodon droppings in this ancient latrine. Since the early 1990s, they’ve been patiently sifting through the only partially digested remains. From it, they’ve been able to piece together a picture of the mastodon in a vanished landscape. The main thing they found was cypress twigs—the mastodons ate vast quantities of cypress, particularly young branches, and particularly in autumn. They also found traces of dozens of other plant species, including some of Janzen’s orphans, such as honey locust, persimmon, Osage orange, and wild gourd. The wild gourd is especially interesting. These days, wild gourds are very rare in the wild. Their extremely bitter rind keeps most living herbivores from snacking on their fruit. It took thousands of years of patient cultivation by Native Americans to turn them into today’s pumpkin and squash.

So next time you have pumpkin pie at Thanksgiving, spare a thought for the wild Cucurbita, the mastodon, which long ago spread its seeds, and all the other ghosts that live on in our orphaned land. And once the meal is over, tell your family about all the amazing things you could learn by stepping back in time to stand in front of a mastodon’s butt.