remove empty reference nodes