Write code to pull data from an API.
Asked in the Round 1 stage as a practical scripting task for a Mandiant security validation role. Implement the pagination and record-processing logic using simulated API responses.
Implement pull_data(pages). pages is a list of response objects in request order. Each response contains an items array of objects and a next field. next is either a string identifying another page or null. Return one array containing records from all pages, removing duplicate records by their id while preserving the first-seen order. Stop after the first page whose next value is null.
def pull_data(pages):