walk in reverse order to expand self-closed tags