I've broken down a longer linq query upon the point where it sometimes crashes. The crash is that Returnattribute is not always found. How to improve the query below so that it will check that it exist and if so get the value or else an empty string (without hanging).
var result = t.Select(x => x.Element(Returnattribute).Value).FirstOrDefault();