Earliest usage of "rope or snake" allegory in Buddhist literature? The allegory of a rope being mistaken for a snake to explain subtle metaphysical points is widespread in Buddhist literature. In particular, Je Tsongkhapa uses this allegory many times in his works to explain subtle distinctions of his formulation of Prasangika Madhyamaka.

I am looking to track down the earliest usage of this rope or snake allegory in Buddhist literature. I have not been able to identify any sutra where this allegory is mentioned, but it occurs many times in later commentarial literature on the perfection of wisdom sutra's as well as in explanations of Nagarjuna's writing.

The earliest usage I have been able to discover is from Chandrakirti's explanation of Aryadeva's Four Hundred Stanzas on the Middle Way (Chatuhshataka). Here is Aryadeva's stanza 178:


  Apart from concepuality,
  Desire and so forth have no existence,
  Who with intelligence would hold [that there are]
  Real things [imputed by] conceptuality?
  
  Aryadeva's Four Hundred Stanzas on the Middle Way


To which ChandraKirti apparently gives this explanation:


  Those which exist only when the conceptuality [apprehending]
  exists and do not exist when conceptuality does not are
  without question definite as not established by way of their
  own nature, like a snake imputed to a coiled rope.
  
  Tsong-kha-pa's Final Exposition of Wisdom


Does anyone know of any earlier or contemporary usages of this allegory in Buddhist literature? Anything that can be traced back to Nagarjuna, Aryadeva, Chandrakirti, Buddhapalita, or Bhaviveka would certainly apply. Of course, if it can be found in sutra that would definitely count as an answer.

Thanks!
For all I know, the simile may come from generic Indian religious tradition and not specifically from Buddhism. For example, here are some quotes from Upanidhads:
Nirvana Upanishad (~ 100 BCE - 100 CE) :


The phenomenal world is impermanent as it is produced [from Brahman
which alone is real]; it is similar to a world seen in a dream and an
[illusory] elephant in the sky; similarly, the cluster of things such as
the body is perceived by a network of a multitude of delusions and it is
fancied to exist as a serpent in a rope.



(Wikipedia:) The composition date or author of Nirvana Upanishad is unknown, but its sutra-style suggests that it originated in the sutra text period (final centuries of the 1st-millennium BC), before it was compiled and classified as an Upanishad. This text was likely composed in the centuries around the start of common era.

Tejobindu Upanishad (~ 100 BCE - 300 CE):


If a man is bitten by a rope mistaken for a snake, then mundane existence may be. If a blazing fire is extinguished by a golden arrow, then the world is.



(Wikipedia:) [...] Eliade's suggestion places these in the final centuries of BCE or early centuries of the CE. [...] Gavin Flood dates the Tejobindu text, along with other Yoga Upanishads, to be probably from the 100 BCE to 300 CE period.

More of these quotes can be found in Advaita Vedanta mail list archives.
And then somewhere around 310-390 CE we see it used by the Yogacara founder Asanga in his Mahayanasamgraha:

How is this entry into Concept-Only made and what is it
like? [...] One enters in the same way that one identifies a rope which seems in the darkness to be a snake. Since it does not exist, the snake seen in the rope is an illusion. Those who have recognized that it does not exist reject the notion of snake and keep the notion of rope. But the rope itself, if reduced to its subtle elements, is an illusion itself, for it has color,
smell, taste and tactile as specific characteristics.
Thus, when any reality has been denied to the six types
of mental words which appear as phoneme or as thing - just as the notion of snake is abandoned by means of the
notion of rope - the notion of Concept-Only underlying the mental words should be abandoned by means of the notion of the absolute nature, just as the notion of rope is abandoned by means of the notion of color, etc.

Since Asanga was originally a brahmin before converting to Buddhism, I wouldn't be surprised if he took this simile from one of the Upanishads and repurposed for Yogacara.
There is also this Sanskrit version of Cittavisuddhiprakarana by Aryadeva (~200-300 CE), but I was not able to find a translation:

sarpabuddhiryathā rajjau rajjudṛṣṭau nivartate|
sarpabuddhiḥ punastatra naiva syādiha janmani||68||
sattvabuddhistathātrāpi vajrajñānānnivartate|
na bhāvaḥ sambhavettatra dagdhabīja ivāṅkuraḥ||69||

Also, this simile appears in Abhidharma Mahavibhasa Sastra which would date it around 150CE: 薩迦耶見計我我所。於勝義中無我我所。如人見繩謂是蛇。 'The satkāyadṛṣṭi thinks about the self and that which belongs to the self; but according to higher truth, there is no self. As for example, a person sees a rope and calls it a snake' (T 1545 (XXVII) 36a18-19)