Caching to improve performance.
If you need to traverse or search compositions frequently, the
Composite class can cache traversal or search information about its
children. The Composite can cache actual results or just information
that lets it short-circuit the traversal or search. For example, the
Picture class from the Motivation example could cache the bounding box
of its children. During drawing or selection, this cached bounding
box lets the Picture avoid drawing or searching when its children
aren't visible in the current window.
Changes to a component will require invalidating the caches of its
parents. This works best when components know their parents. So if
you're using caching, you need to define an interface for telling
composites that their caches are invalid.