Assuming it's well-behaved (no cycles, no duplicate names or multiple parents for one child) you could simply use a "directed graph" and traverse it. To find the root(s) I also used a dictionary containing a boolean that indicates if there is any parent for the name:
lst = [('john','marry'), ('mike','john'), ('mike','hellen'), ('john','elisa')]
# Build a directed graph and a list of all names that have no parent
graph = {name: set() for tup in lst for name in tup}
has_parent = {name: False for tup in lst for name in tup}
for parent, child in lst:
graph[parent].add(child)
has_parent[child] = True
# All names that have absolutely no parent:
roots = [name for name, parents in has_parent.items() if not parents]
# traversal of the graph (doesn't care about duplicates and cycles)
def traverse(hierarchy, graph, names):
for name in names:
hierarchy[name] = traverse({}, graph, graph[name])
return hierarchy
traverse({}, graph, roots)
# {'mike': {'hellen': {}, 'john': {'elisa': {}, 'marry': {}}}}