Use an instanceof Element check and alter method signature for clarity