A flight traveling from Dubai to Budapest diverted to Dubai after the first officer became mentally unstable.