Written in 1916, A Connection Between a Symbol and a Symptom is a small piece written by Sigmund Freud in which he explores the link between the hat symbol and its representation of the male genital. In the piece he suggests that the hat symbol receives this meaning through its link with the head and having drawn this conclusion he goes on to outline the link between the head/hat symbol and obsessional symptoms.
He first outlines that the image of a head being cut off is a particularly disturbing form of death precisely because it reminds a person of castration, a further activity that a person will find distasteful and disturbing. He suggests than that tipping a hat in greeting links back to this idea and qualifies an existing symptom in obsessional neurotics. He recalls that in some cases the tipping of a hat has an important role for the obsessional. In performing the activity you are ceding power to the other person but if they respond in a like manner a balance is restored. Should either party neglect to tip their hat there is the unconscious message that they are above their colleague.
Freud, S (1957/2001) 'A Connection Between a Symbol and a Symptom' in The Complete Psychological Works of Sigmund Freud Vol. XIV (Strachey, J. trans.), Vintage, London.