The Composite Design Pattern

Introduction

Networks and hierarchies are ubiquitous in many domains.

Structure

Behavior

Discussion

In a hierarchy a component has at most one parent and there are no cycles in the parent-child association. In other words, no component can be an ancestor of itself.