In this quote by Hogwarts nurse Madame Pomfrey she emphasizes that thoughts of sorts could leave only hurt behind in one's head. If Sigmund Freud was to have seen this quote, he would be immediately understanding of this. For example Freud thought people could let out small hints at a troubling past, on the other hand Freud would think this could be some form of repression. In that Madame Pomfrey leaves behind subtle remarks about possible tough memories, this causing her to look back to these troubling thoughts she could have once had. This is only the basic touch upon, possibly Freud suspects more to this.
Another theory behind this statement could possibly be Sublimation, redirecting a forbidden desire to a socially accepted desire, noting