This happens to me pretty often, most recently just a day or two ago. I was trying to come up with a folk ballad, and was happy with what I had after about an hour of work, only to recognize it as something I have already heard.
When this happens to me, If I DO identify the melody I try to go back further and find an even earlier use of the melody. I regard this as licence to use what I came up with. There's nothing new under the sun.
Back when I played gigs I had a fake book I bought that had this weird index in the back to help the performer identify tunes by it the notes went up or down or stayed the same. So "The Star Spangled Banner" might look something like:
D-D-D-U-U-U-U-D-D-D-U-U -S-S-U etc.
Pretty laughable. Us guys use to play "Name that Tune" trying to use it in reverse. Never once did any of us get one right.
Here are a couple of my heartaches, one for the tune and a couple for titles.:
A lullaby I wrote in the 70's (but never copyrighted) opens exactly like "A Whole New World" from Disney's "Aladdin". Made me feel bad I didn't have it registered, but then I recalled "I Left My Heart in San Francisco" and felt better.
I have a song called "Let It Go" copyright 2009, probably before the "Frozen" song of the same name. BTW I'm getting quite a few looks at it on SoundClick the last few days. Also, I just learned that Def Leppard had a "Let It Go" back in the early 80's. Mine doesn't sound like either.
I wrote a song called "Come Away With Me", only to learn there was a big country(?) hit of the same name not all that long before I wrote mine....but I felt better when I recalled the barbershop that opens with "Come away with me Lucille - In my merry Oldsmobile" from before you or I were born.
I have more that I can't even remember anymore. I don't worry too much about it.