In the Jazz world the saying is "Giants stand on the shoulders of Giants"
I have taught copyright a few times. Unless your melody is an excat copy of another for the whole length of the tune, note for note, timing for timing then NO you are not ripping anything off and you will
not be prosecuted even if you release it. As a composer of many jingles I have many times had to create what we call 'look alikes' where exact melodies are copied and only the
slightest thing is changed to avoid any prosecution. Sad isn't it.
I say go right ahead and do what you want. It is more about how you personally feel in terms of creating something that might sound similar to something else that is all. But hey that is not a bad thing either. It means you are pretty good at what you are doing if you are coming up with things that are close to other great things.