What to group planets, moons, and stars under?

Solution 1:

If you want a objective sounding word, consider using 'body' or 'bodies'. Taken from the scientific context ie three body problem. This would make a good general variable name.

If you want something more earth-centric, or human-centric, then the phrase 'celestial body' might also work. Although this is often used to describe all bodies but earth itself, so it may or may not make sense in your context.