TeX has some primitives for “looking back” and removing a node, storing it into a register: \lastskip, \lastkern, \lastpenalty and \lastbox. Other types of nodes can't be examined nor removed.
Note that \lastskip only keep information about the size of the last skip, whether it comes from a “real” skip or \leaders, so the information about leaders is lost in this case.
All of them do nothing, in the sense that they store a null value, if the last node is of the requested type. As usual, boxes are special: \lastbox by itself will remove the last box (if the last node in the list is a box), and reinsert it (see Usage of \lastbox).
However, a rule node is not a box, so \lastbox will do nothing sensible. More explicitly: you can't remove a rule node nor examine it.
\lastbox. Rules don't. And there's no way to remove them from a list, unless you produce them as a vertical leader (and\unskipwill remove them). If you look at the macro I suggested, I removed\noalign{\hrule}in the first pass just because of that problem. – egreg Oct 08 '14 at 17:45