kishi created madara from Jum sum (枕神) god mythology.Jum sum is the Chinese god of sleep ,also of dreams. Originating sometime in the 1st century BC and almost a forgotten deity.Sleep & dream resemble Madara's infinity tsukuyomi plan. keep your minds i'am not talking about itachi's tsukuyomi it based on another japanese myth(tsukuyomi the moon god).
what do u think guys/girls
this info based on my own thoughts & encyclopedia sites :D