human
Solve in Python:
A kingdom consists of a king, his children, his grandchildren, and so on. Every once in a while, someone in the family dies or a child is born.
The kingdom has a well-defined order of inheritance that consists of the king as the first member. Let's define the recursive function Successor(x, curOrder), which given a person x and the inheritance order so far, returns who should be the next person after x in the order of inheritance.
Successor(x, curOrder):
    if x has no children or all of x's children are in curOrder:
        if x is the king return null
        else return Successor(x's parent, curOrder)
    else return x's oldest child who's not in curOrder

For example, assume we have a kingdom that consists of the king, his children Alice and Bob (Alice is older than Bob), and finally Alice's son Jack.

In the beginning, curOrder will be ["king"].
Calling Successor(king, curOrder) will return Alice, so we append to curOrder to get ["king", "Alice"].
Calling Successor(Alice, curOrder) will return Jack, so we append to curOrder to get ["king", "Alice", "Jack"].
Calling Successor(Jack, curOrder) will return Bob, so we append to curOrder to get ["king", "Alice", "Jack", "Bob"].
Calling Successor(Bob, curOrder) will return null. Thus the order of inheritance will be ["king", "Alice", "Jack", "Bob"].

Using the above function, we can always obtain a unique order of inheritance.
Implement the ThroneInheritance class:

ThroneInheritance(string kingName) Initializes an object of the ThroneInheritance class. The name of the king is given as part of the constructor.
void birth(string parentName, string childName) Indicates that parentName gave birth to childName.
void death(string name) Indicates the death of name. The death of the person doesn't affect the Successor function nor the current inheritance order. You can treat it as just marking the person as dead.
string[] getInheritanceOrder() Returns a list representing the current order of inheritance excluding dead people.

 
Example 1:
Input
["ThroneInheritance",...

=====
Give me a the Python program you requested?
assistant
#Here is the Python program you requested.

class Person:
    def __init__(self, name):
        self.name = name
        self.alive = True
        self.children = []

class ThroneInheritance:

    def __init__(self, kingName: str):
        self.king = Person(kingName)
        self.name_person_map = {kingName: self.king}

    def birth(self, parentName: str, childName: str) -> None:
        parent = self.name_person_map[parentName]
        child = Person(childName)
        parent.children.append(child)
        self.name_person_map[childName] = child

    def death(self, name: str) -> None:
        person = self.name_person_map[name]
        person.alive = False

    def getInheritanceOrder(self) -> List[str]:
        res = []
        self.preorder_dfs(self.king, res)
        return res
    
    def preorder_dfs(self, person, res):
        if person.alive:
            res.append(person.name)
        for child in person.children:
            self.preorder_dfs(child, res)
        

# Your ThroneInheritance object will be instantiated and called as such:
# obj = ThroneInheritance(kingName)
# obj.birth(parentName,childName)
# obj.death(name)
# param_3 = obj.getInheritanceOrder()