Added contains function which checks whether the passed element is a descendant