Using the Visitor pattern