tree handles selection correctly while refreshing