Replace an element with another element.
the new element
the element to be replaced
whether replacing the element was successful