It is possible that what you're looking for here is the Visitor pattern. If you have an object as you describe, with a number of non-trivial member fields, and you find that you have a number of different
functions that all traverse this data structure in the same way, the visitor pattern can be very helpful in reducing the amount of code duplication. It is not automatic, through, you have to write the functions that traverse all the member fields, but you
only have to do that once, and you can use it many times over with different visitor classes that do different things.
The visitor pattern does involve writing quite a bit of code, you need an abstract base class for the visitors:
virtual void enter(Example& e)=0;
virtual void leave(Example& e)=0;
virtual void enter(AnotherClass& e)=0;
virtual void leave(AnotherClass& e)=0;
Then you need accept functions in all the classes that are going to be visited:
void Example::accept( VisitorBase& visitor )
And finally you need to implement concrete visitor classes that do the actual work you're interested in, which generally amounts to gather information from the data structure, making changes to the data structure, or combinations of both. Google Visitor pattern
and you'll find lots of help on this.