class RunGraph:
    def __init__(self, id):
        self.id = id

    def run(self, indent):
        pass

    def search(self, id):
        if self.id == id:
            return self
        else:
            return None

    def __str__(self):
        return "<Graph: " + self.id + ">"

class Leaf(RunGraph):
    def __init__(self, id):
        RunGraph.__init__(self, id)

    def run(self, indent):
        print indent + "Running Leaf " + self.id

class Node(RunGraph):
    def __init__(self, id, children):
        RunGraph.__init__(self, id)
        self.children = children

    def run(self, indent):
        print indent + "Running Node " + self.id
        for c in self.children:
            c.run( indent + " ")

    def search(self, id):
        if self.id == id:
            return self
        else:
            for c in self.children:
                result = c.search(id)
                if result != None:
                    return result
        return None

theLeaf = Leaf("D")
theGraph = Node("A", 
            [ Node("B", [theLeaf]),
              Node("C", [theLeaf])] )

theGraph.run("")
g = theGraph.search("C")
print str(g)

print "done."