Presume this is a quill stem and the nut you are referring to is the expander nut that is used to tighten the stem and the stem has now been removed?
Can you re fit the long stem bolt back into the head, loosely fitted and than tap it with a hammer to loosen it, then pull it out with the bolt still screwed in?
Alternatively, is the nut far enough down, so that it doesn't interfere with a new quill stem, in which case, no harm in leaving it there.
Good luck