Dementia is proving very difficult to treat with medicine, but perhaps there are secret, brain-boosting ingredients already hiding in our diets.

A study of more than 50,000 participants in the UK Biobank has found that people who eat a handful of nuts every day could be lowering their risk of all-cause dementia.

Compared to people over the age of 60 who don't eat nuts, those who reported consuming up to 30 grams of nuts a day had a 16 percent lower risk of developing dementia in the years to come.

If the nuts were consumed unsalted, that number jumped to 17 percent. It didn't matter if nuts were hulled, dried, roasted, or peeled.

That sounds like good news, but there are a few caveats. These results were only found in those who are not considered obese, who get a normal amount of sleep, and who do not smoke tobacco, or drink alcohol daily.

No significant associations were found when only men across all age groups were considered, or in those who report other risk factors, like muscle weakness or feelings of loneliness.

"Future long-term follow-up studies, both observational and clinical trials, should evaluate the efficacy of nut consumption as a strategy for preventing dementia in adults," write researchers from the University of Castilla-La Mancha in Spain.

This isn't the first time that nuts have been linked to brain health. Nuts are energy-dense foods that are rich in anti-inflammatory and antioxidant nutrients and compounds.

Scientists have, therefore, hypothesized that the properties of nuts could have benefits to brain health, and some epidemiological studies certainly suggest that could be the case.

In a 12-week randomized controlled trial, researchers found that a handful of daily peanuts enhanced short-term memory and verbal fluency in healthy, middle-aged adults who were overweight.

A few other clinical trials, however, have found no such benefits.

To clear up the murky results, health researcher Bruno Bizzozero-Peroni and his colleagues at Castilla-La Mancha drew on a cohort from the UK Biobank, enrolled between 2007 and 2012.

Participants were tracked for an average of 7 years. Over the course of the study, the rate of all-cause dementia was 2.8 percent. Those who said they ate 30 grams of nuts a day (equivalent to about a handful) were less likely to fall into that risk category.

The reasons behind that association are unclear. At this point it's not clear what leads to different forms of dementia, let alone what is capable of preventing them, and why.

"To date, pharmacological treatment for dementia has demonstrated only modest beneficial effects, especially in terms of preventing disease progression," write Bizzozero-Peroni and his colleagues.

Still, emerging evidence suggests that as many as 40 percent of dementia cases can be prevented or even delayed by modifying certain lifestyle risk factors, like smoking, drinking alcohol, exercising, or social isolation.

Diet seems to be a crucial player. In the past, several systematic reviews have found healthy diets, like the Mediterranean diet, are linked to a reduced risk of dementia. Meanwhile, the Western diet, which is high in saturated fat, sugar, and salt, seems to be a risk factor for dementia.

A recent study on 60,000 Britons found that adhering to a Mediterranean diet decreases the risk of dementia by as much as 23 percent.

Further research revealed that olive oil, a staple of the Mediterranean lifestyle, may specifically lower the risk of dementia-related death by 28 percent.

Those are really promising numbers that need to be studied further, especially since only a quarter of the UK biobank cohort reported regularly eating nuts.

The study was published in GeroScience.