Deterministic finite state machine for GetElements()