a kingdom consist king child grandchild every family die child bornthe kingdom welldefine order inheritance consist king member Lets define recursive function Successorx curorder give person x inheritance order far return person x order inheritancesuccessorx curorder x child xs child curOrder x king return null return Successorxs parent curorder return xs old child who s curOrderFor example assume kingdom consist king child Alice Bob Alice old Bob finally alice son jackin begin curorder kingcalle successorke curorder return Alice append curorder king AliceCalling SuccessorAlice curorder return Jack append curorder king Alice JackCalling SuccessorJack curorder return Bob append curorder king Alice Jack BobCalling SuccessorBob curorder return null Thus order inheritance king Alice Jack BobUsing function obtain unique order inheritanceimplement ThroneInheritance classthroneinheritancestre kingname initialize object ThroneInheritance class the king give constructorvoid birthstre parentName string childname Indicates parentName give birth childnamevoid deathstre indicate death the death person do not affect Successor function current inheritance order you treat mark person deadstre getInheritanceOrder return list represent current order inheritance exclude dead people Example 1inputthroneinheritance birth birth birth birth birth birth getinheritanceorder death getinheritanceorderking king andy king bob king catherine andy matthew bob alex bob asha null bob nullOutputnull null null null null null null king andy matthew bob alex asha catherine null king andy matthew alex asha catherineexplanationthroneinheritance t new ThroneInheritanceking order kingtbirthke andy order king andytbirthke bob order king andy bobtbirthking catherine order king andy bob catherinetbirthandy matthew order king andy matthew bob catherinetbirthbob alex order king andy matthew bob alex catherinetbirthbob asha order king andy matthew bob alex asha catherinetgetInheritanceOrder return king andy matthew bob alex asha catherinetdeathbob order king andy matthew bob alex asha catherinetgetInheritanceOrder return king andy matthew alex asha catherine Constraints1 kingnamelength parentnamelength childnamelength namelength 15kingname parentName childname consist lowercase english letter onlyall argument childname kingname distinctAll argument death pass constructor childname birth firstfor birthparentName childName guarantee parentname aliveat 105 call birth deathat 10 call getinheritanceorder