Get list of unique parents from childrens list
Your use of var is good, but names like temp is meaningless. It's a temp what exactly? A more descriptive name is in order here. 

The call to ToList appears to be redundant. Hashset's constructor takes an IEnumerable&lt;T&gt; and Linq queries that return collections already return one.

I would also break the query away from the ctor for readability purposes. 

var parents = from child in program.Children
                 select child.Parent;

var distinctParents = new HashSet&lt;Parent&gt;(allParents);


However, it's all kind of moot if you use the method syntax snippet that @RobH posted. 


var parents = program.Children.Select(c =&gt; c.Parent).Distinct();