tree edit function