class WNode(object):
def __init__(self,w):
self._w=w
self._content=[]
def find(self, x):
if self._w is x:
return self
else:
for i in self._content:
return i.find(x)
return None
Hi. I'm having troubles to create a method tree.find(self,x) that returns the node with the name x in the tree if x is present (using recursion). The one that i wrote seems to be working only in certain cases(in simple trees with few levels) but in others(especially in larger trees) it returns None even if a node is present. Somebody knows how to create a working find(self,x) method that returns the x node?