Approval process causing duplicates

Approval process causing duplicates

I have a workflow function that searches a module for a lookup field that matches the relevant id.  If it exists, it updates the record.  If it doesn't exist, it creates it.  This process worked perfectly until I added an approval process.

Now, if a record is awaiting approval it doesn't find the record when it does search. As a result a duplicate is created.  That duplicate also meets the approval criteria and enters the approval process itself....  I'm in an ongoing cycle of duplicate creation!!

Is there a way that I can get my function to also search the records awaiting approval before creating a new one?