Added is_element_empty helper function