* @param toElement true to use {@link Event#getRelatedEventTarget()}
* @return the within state
*/
public final boolean within(Element element, boolean toElement) {
if (Element.is(element)) {
EventTarget target = toElement ? getRelatedEventTarget() : getEventTarget();
if (Element.is(target)) {
return element.isOrHasChild((Element) target.cast());
}
}
return false;
}