Ensure before argument is of type Element

Ensure argument before is of type Element before calling methods on it.