By the Tokugawa period, the training of the Samurai warrior (or Bushi) and his role in society had created within him a preoccupation with four subjects: Duty, Honor, Obedience, and Death. He slid into an unreserved commitment with his creed (Bushido), and was so rigidly bound by it that his life, and indeed the life of his family, was not his own. For the sake of his honor he would unhesitatingly go into battle or commit seppuku (suicide).
A specific translation of the word Samurai is 'servant' or 'he who serves', which denotes clearly that they were men who served a master; therefore, the primary function they were professionally called upon to perform was that of unquestioningly carrying out any and all orders issued by those superiors to whom they had pledged their loyalty and that of their families. This oath bound each retainer directly to the leader he had chosen (or inherited) as his lord and who had accepted his oath. This oath was so binding and exclusivistic that it actually provided a serious obstacle to the further development of the military class, for when the various leaders fought among themselves ( as they did for centuries ), their warriors for the most part followed them into one decimating battle after another, until at last all the clans were united by the Tokugawa.
The Bushi pledged his loyalty in a ceremony whose rituals were drawn from Shinto, with its emphasis on the cult of ancestors. The pledge was inscribed on a scroll (kishomon) with a brush dipped in the warrior's blood (keppan), then burned before the deities venerated by that particular clan. The ashes were than dissolved in liquid and swallowed by the Samurai. The oath was inscribed in the clan's records, and the retainer, his family, and his dependants became totally identified with their master whose desires and wishes became, from that moment on, their own. So all-encompassing was the bond that when a master died (even of natural causes) many of his retainers followed him in death even as they had followed him in life. In battle, the retainer fought under his direct superior's command, carried out his orders, and protected any retreat.
Should his superior wish to evade capture by committing seppuku, the retainer acted as his second, who had the duty of shortening the agony by cutting off the superior's head. If ordered to fight to the bitter end, he would do so. If permitted, he would follow the ancient custom of the martial tribes who never willingly allowed themselves to be captured by an enemy, preferring death. Any surrender terms offered by an enemy, even as an effort to prevent needless bloodshed, were considered an insult (when not simply a hilarious notion). In order to enable a Samurai to overcome fear of death, he was trained to think of himself as a man whose life was not his own. His code of honor (Bushido) and all the classics relating to it stressed the point of never pausing to ponder the nature, significance, or effects of a superior's command, lest reasoning make a coward of him.
To further illustrate the loyalty of the Samurai, I have added one of those stories that everyone knows, but no one knows who the real characters in the story are. It is the story of a diyamo (the European equivalent is a baron).