* apply visitor pattern for tree structures