Symbolism, Imagery, Allegory
Ahithophel's counsel is considered to be equal to that of an "Oracle of God"—and even though he turns traitor to David, he evidently does give pretty good advice to Absalom.
Maybe if Absalom had taken Ahithophel's advice, he'd have won the battle with David, but according to the narrator, God made Absalom take Hushai the Archite's advice instead. Considering that the Hushite was working for David, this didn't work out too well. Ahithophel was so broken up over Absalom's refusal to take his counsel, that he went home and hung himself.
This story is, in a sense, mirrored by the Christian Bible's tale of Judas Iscariot's betrayal of Jesus. Filled with regret, Judas hangs himself—which is the same method Ahithophel uses to kill himself. Since the Gospels chart Jesus' descent from King David on Joseph's side of the family, and since David is God's "Beloved"—almost like a son—the Judas and Jesus parallels are pretty striking.