What is the origin of "Trick-or-treat"?

Hint: It kinda sounds like the beginnings of the mafia.