The Visitor design pattern provides a solution:
Define a separate Visitor object that implements operations to be performed on the elements of an object structure.
Clients traverse the object structure and call accept(visitor) on each element to delegate the request to the "accepted visitor object".
The visitor object then performs the request ("visits" the element).
Describing the Visitor design in more detail is the theme of the following sections. See Applicability section for all problems Visitor can solve.