People with type 2 diabetes have a higher than average risk of developing heart disease. But there's an easy way to reduce that risk: eat a handful of nuts.

Researchers at Harvard TH Chan School of Public Health looked at food frequency questionnaires collected from over 16,000 men and women before and after they were diagnosed with type 2 diabetes. They were specifically interested in seeing how eating nuts might affect the risk of developing cardiovascular disease. Study participants were asked about how many servings of nuts they ate each week, both peanuts and tree nuts, over the past several years.

Tree nuts, such as walnuts, almonds, cashews, pecans, hazel nuts, pistachios, macadamias and pine nuts, offered greater protection from heart disease than peanuts.

Over the course of the study, 3,336 people were diagnosed with cardiovascular disease, including 2,567 cases of heart disease and 789 strokes. There were 5,682 deaths, and roughly a third of them were due to cardiovascular disease.

The chance of heart disease was about 20 percent lower among people with diabetes who ate five or more one-ounce servings of certain nuts a month, compared to those who ate less than a serving of nuts a month. Five or more servings of nuts a week also dropped the risk of premature death from heart disease or any other cause by about a third. Even after researchers adjusted for other risk factors for heart disease, eating nuts was still associated with a lower risk of heart disease.

Not all nuts are created equal though. Tree nuts, such as walnuts, almonds, cashews, pecans, hazelnuts, pistachios, macadamias and pine nuts, offered greater protection from heart disease than peanuts, which are not nuts but legumes that grow in the ground.

What makes nuts so beneficial? They reduce inflammation in the body and improve the health of blood vessels. They also help to control blood sugar, blood pressure and cholesterol levels, all of which are good news for those with type 2 diabetes.

Nuts contain beneficial unsaturated fatty acids, fiber, vitamin E and magnesium; but they are also high in calories and fat, and so are not a food you can eat freely, despite their health benefits. The fat they contain is a healthy fat, but the weight gain from eating too many nuts would quickly cancel out the benefits of eating several small portions of nuts each week.

A serving of nuts — about an ounce — should just fill your palm. Avoid salted nuts since the salt can increase your risk of heart disease or stroke. Raw, unsalted nuts are best.

The study is published in Circulation Research.