The first part of the melody uses a minor triad with the added 9 over the ii chord (D-7 would use a d minor triad with the 9th “E” added). The second part of the melody uses the minor triad with an added 9th one half step above the root (G7 would use an Ab minor triad with the 9th “Bb” added) or a tritone away from the first triad. This triad with added 9 over the dominant produces an “altered” sound giving you b9, #9, 3 and #5 on the dominant and comes from the 7 mode of melodic minor or altered scale). The line resolves to the 5th of the I chord… Try singing the line slowly at the piano to learn to hear it well before playing it on your primary instrument.
My friend Miles mentioned to me that Stefon Harris refers these triads with any single added note as “quadrads”. A quadrad can basically be thought of as a 4 note scale.
Once you’ve worked on this simple melody through the keys try improvising using the 4 note “quadrads” over the same ii – V – I progression. Last, try to use the quadrads over a standard or original you enjoy improvising on. This should help the new sound eventually become part of what you hear.