Keeping track of these relationships can be complicated.

“People have long hypothesized that living in complex society is one of the reasons why we’ve evolved such large brains,” Dr. Farine said. Researchers have found evidence for multilevel societies in some other large-brained mammals, such as monkeys, elephants, giraffes and sperm whales. But as Dr. Farine studied baboons, he also watched the vulturine guineafowl wandering around his study site.

“I was really struck by the social behavior that they exhibited,” he said.

These hefty birds can fly, but rarely choose to. Instead, they stroll across the landscape in packs, often walking so closely that their bodies touch. They may chase each other or fight to maintain their strict hierarchies. But at other times they engage in friendly behaviors like sharing food. Their groups are unusually large for birds, sometimes including 60 or more individuals. And while most other social birds are very territorial, Dr. Farine says, groups of vulturine guineafowl don’t mind sharing turf.

He suspected the guineafowl might have a social structure just as interesting as baboons. So he and his colleagues began an intensive study of vulturine guineafowl society at the Mpala Research Center in Nanyuki, Kenya. For a year, they made daily observations of 441 birds — nearly every adult in the local population. They counted 18 groups in total. Colored leg bands in unique combinations let researchers tell the black-and-blue birds apart. Scientists also attached little solar-powered GPS devices to the backs of 58 birds, including one or more in each group. This let them see exactly where every group went, 24 hours a day, for a whole year.

They found that group membership was stable; birds stuck with their pack.

Each group included multiple breeding pairs, along with other birds. Groups often met and interacted — in fact, certain groups seemed to prefer hanging out together. Some groups even bunked together at night.

“Even though they did not share the same home range during the day, they seemed to seek each other out at night and roost together,” Dr. Farine said.