'''
# dfs means traverse as deep as you can before going back to your parent.

dfs: 
Time:O(V+E)
space = O(V), worst case we make a call stack for every vertex.

'''

class Node:
    def __init__(self, name):
        self.children = []
        self.name = name

    def addChild(self, name):
        self.children.append(Node(name))
        return self

    def depthFirstSearch(self, array):
		
        # recursive call on the child
		array.append(self.name)
        for child in self.children:
            child.depthFirstSearch(array)
        return array