public Class GetVariant(SimpleType type, Context context) { var variant = Variants.Prepend(this) .Where(i => i.TemplateList == null) .Select(i => i.Matches(type, _context)) .FirstOrDefault(match => match != null); if (variant != null) { return(variant); } return(Variants.Prepend(this) .Where(i => i.TemplateList != null) .Select(i => i.Generate(type, context)) .FirstOrDefault(match => match != null)); }