dic = {'2': ['1'], '3': ['1', '2', '6'], '4': ['1', '3', '6', '8'], '5': ['2'], '6': ['2', '7', '8'], '7': ['2', '10', '8'], '8': ['2', '5'], '9': ['2', '3'], '10': ['8']}
def allChild(parent, res=[]):
global dic
if parent in dic:
try:
for i in dic[parent]:
res.append(i)
for i in dic[parent]:
for elem in allChild(i):
if elem not in res:
res.append(elem)
except:
return res
return res
print(allChild('3'))