def get_expanded_ast(self, filepath): ast = self._parser.parseFile(filepath) new_children = [] for child in ast.getChildren(): if child.getName() != 'include': child.addChild(AstNode('origin', filepath)) new_children.append(child) else: for inclpath in child.getChildren(): for new_child in self._resolve_include(inclpath): new_children.append(new_child) ast.removeChildren() for child in new_children: ast.addChild(child) self._expanded_asts[filepath] = ast return ast