Added visitor to serialize tree + tests