Regarding Islamic succession law, If you convert it into cases, it will be massive more than 5000 cases, and if you convert it into a computer program, it may give you conditions that you may have to spend hours calculating. It covers more than 25 ascendants and descendants generations until your distribution finishes. Sunni Muslim Succession law derives from four sources: the Holy Quran, Sunnah, Qiyas, and Ijma.
The Law of Islam and its inner dimensions are not easy to understand because Sharia includes all actions and moments of a Muslim’s life, and that’s why it is distinct from the law in the modern sense. Law in Islam is divine guidance which is infallible and eternal. Legal laws, however, are limited in scope and extinguished after a person’s death. The divine guidance of Islam cannot be attained in its entirety, even though the entire world was given a task to accomplish. That's why the debate and discussion do not settle regarding Islam and shariah.
The Holy Quran is the first and primary Islamic inheritance source. The sharer prescribed in the Holy Quran is called "Zav-il-Furuz" in Arabic. Holy Quran Verses 4:11, 4:12, and 4.176 are the main sources of fixed sharers. The Holy Quran's verses that deal directly with testamentary disposition are 2:180-182, 2:240, 4:33, and 5:106-107.
The sayings of the Prophet Mohammad (Sallallahu Alayhi Wasallam) which has been narrated by a companion of the Prophet through authentic chains of Hadith. A large wealth of the Prophet’s traditions relating to succession has been compiled in volumes. This includes the share of Sisters (as a Residuary, i.e., Al-Asbah, See Hadith: Sahih al-Bukhari 6736, Book 85, Hadith 13 ), Grandmothers, and succession through Friendship bond (called “Wala” in Arabic). Also include succession through Relations as authenticated in the book: Sahih al-Bukhari, Volume 8, Book 80 Laws of Inheritance, Number 724 and narrated Ibn Abbas: “The Prophet said, Give the Faraid (the shares prescribed in the Holy Quran) to those who are entitled to receive it. Then whatever remains should be given to the closest male relative of the deceased.” (Ref. Inheritance Law Rules and Shares by Mohammad Razi).
Ejma or Ijma
Ejma is the third source of Islamic law. It's the leading companions' consensus of the Prophet Muhammad (Sallallahu Alayhi Wasallam), including Abu Bakr, Omar Farooq, Osman Ibn-Affan, and Ali (may Allah shower blessings on them all!) and also the learned members of a community or the Muslim community as a whole, which is another crucial indicator of balanced opinion and judgment in Islam. Notwithstanding a degree of technicality in the detailed formulations of "ijma," its inherent strength as a source of law, judgment, and moderation can hardly be overestimated. (Ref. The Mahomedan Law - according to the school of Shafii by C.H. Withers Payne, LL.D. (London). There is consensus on treating Grandson how low soever as Son, Granddaughter how low soever as Daughter (provided later is nonexistent), Grandfather how high soever as a Father when Father is nonexistent, and treating Paternal Sister as a Full sister when Full sister is not alive (Ref. Inheritance Law Rules and Shares by Mohammad Razi).
Qiyas is the last source of Islamic law when Ijma is not possible. It's the exercise of private judgment using reason and analogical deduction based on the Islamic Jurisprudence Framework in light of the Holy Quran and Hadith. It includes True Grandfather (i.e., Father of Father how high soever), True Grandmother (i.e., Mother of Father, Mother of Mother how high soever), and Granddaughters (Daughters of Sons how low soever). However, there is a slight difference of opinion among four Islamic jurisprudence schools called Hanafi, Shafii, Maliki, and Hanbali.
Allah, the Most Glorified and the Most High, knows the best. As a human, We are limited to everything and can not perceive it in totality...