def select_leaves(self, name):
if self.is_leaf:<EOL><INDENT>return [self] if re.search(name, self.label) else []<EOL><DEDENT>else:<EOL><INDENT>leaves = []<EOL>if re.search(name, self.label):<EOL><INDENT>for c in self.children:<EOL><INDENT>leaves += c._get_leaves() <EOL><DEDENT><DEDENT>else:<EOL><INDENT>for c in self.children:<EOL><INDENT>leaves += c.select_leaves(name) <EOL><DEDENT><DEDENT>return leaves<EOL><DEDENT>
Returns all leaves under all nodes matching name