In Ayurvedic view, Shami is considered to be extremely potent medicine. Although Shami is inhabited by many deities, it is considered to be the beloved of Lord Shiva and Ganesha. Shani is very much loved by both Shree Ganesh and Lord Shani.
Due to worship of Shami tree, grace can be obtained by both Shani Dev and Lord Ganesha. Lord Shiva resides in this plant himself, who is the father of Ganesh ji and Guru of Shani Dev.