Line 324-332 should be a method called (for example) `isPopup(element)`.