def propertySearch()

in pachi_py/pachi/tools/sgflib/sgflib.py [0:0]


	def propertySearch(self, pid, getall=0):
		"""
			Searches this 'GameTree' for nodes containing matching properties.
			Returns a 'GameTree' containing the matched node(s). Arguments:
			- pid : string -- ID of properties to search for.
			- getall : boolean -- Set to true (1) to return all 'Node''s that
			  match, or to false (0) to return only the first match."""
		matches = []
		for n in self:
			if n.has_key(pid):
				matches.append(n)
				if not getall:
					break
		else:	# getall or not matches:
			for v in self.variations:
				matches = matches + v.propertySearch(pid, getall)
				if not getall and matches:
					break
		return GameTree(matches)