Finished valid push/pop sequence function.