are there any electrons in T left unused?
 i.e. is
T ≠ 0?
does any terminal atom need more electrons to form an octet?

Oxygens ending in H are considered terminal for the purpose if this algorithm. These are prioritiezed over other terminal oxygens that do not have H attached.

if you ran out of terminal atoms and you have a long formula, consider inner atoms that are not the central one to be next in line to receive electrons. Treat these the same as you would treat the above terminal atoms.
continue
  T = 0   continue  
  continue