Re-added function to count measures before a given element