added use of isLeaf() in replace and delete iterator