<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def parse_emails(self, email_filename, index=0):
 """Generator function that parse and extract emails from the file `email_filename` starting from the position `index`. Yield: An instance of `mailbox.mboxMessage` for each email in the file. """

        self.log("Parsing email dump: %s." % email_filename)
        mbox = mailbox.mbox(email_filename, factory=CustomMessage)

        # Get each email from mbox file
        #
        #   The following implementation was used because the object
        #   mbox does not support slicing. Converting the object to a
        #   tuple (as represented in the code down here) was a valid
        #   option but its performance was too poor.
        #
        # for message in tuple(mbox)[index:]:
        #     yield message
        #
        key = index
        while key in mbox:
            key += 1
            yield key-1, mbox[key-1]