Improved Pattern matching to match exactly the penultimate node