visitor changes to only visit subtree if it has been modified