This is the Composite pattern, one of the "Gang-of-Four" design patterns (check out their book!).
6.2m questions
8.2m answers