(TRYING NOT TO INCLUDE SPOILERS BY GIVING A KIND OF VAGUE DESCRIPTION)
In Shutter Island, DiCaprio plays U.S Marshall Edward "Teddy" Daniels sent to a psychiatric facility for the criminally insane on said island to investigate an escaped patient, Rachel Solando. After reading the synopsis, that gave away no more information than the above, I immediately knew that the twist in the ending would be that Daniels was a patient on Shutter Island himself, it was inevitable.
Similarly, the twist ending in the script I was in the process of writing was exactly the same. A medicine student shadows an esteemed psychiatrist in an institution, only for it later to be revealed that this is the hallucinations and ideas coming from a brain-damaged girl, in a coma after attempting suicide by hanging and damaging her nervous system.
Credit to Scorsese, he must have had an idea that when it comes to mental health dramas there are only a select few twist endings that are effective. He took one we probably would have suspected first, but developed it, with the use of characters Rachel Solando and Andrew Laeddis and the use of the "law of four" and the question of who is "patient 67"?