In a state of extreme sleep deprivation, the dream state can impinge upon the waking state, and the two states of consciousness can merge, resulting in hallucinations. Perhaps this might explain how psychosis might arise as a result of sleep deprivation.