def _find_calls(self, ast_tree, called_module, called_func):
s = set()<EOL>s.add("<STR_LIT>".format(called_module, called_func))<EOL>if hasattr(ast_tree, '<STR_LIT:body>'):<EOL><INDENT>if isinstance(ast_tree.body, collections.Iterable):<EOL><INDENT>for ast_body in ast_tree.body:<EOL><INDENT>s.update(self._find_calls(ast_body, called_module, called_func))<EOL><DEDENT><DEDENT><DEDENT>elif hasattr(ast_tree, '<STR_LIT>'):<EOL><INDENT>if hasattr(ast_tree, '<STR_LIT>'):<EOL><INDENT>if ast_tree.module == called_module:<EOL><INDENT>for ast_name in ast_tree.names:<EOL><INDENT>if ast_name.name == called_func:<EOL><INDENT>s.add(unicode(ast_name.asname if ast_name.asname is not None else ast_name.name))<EOL><DEDENT><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>for ast_name in ast_tree.names:<EOL><INDENT>if hasattr(ast_name, '<STR_LIT:name>') and (ast_name.name == called_module):<EOL><INDENT>call = "<STR_LIT>".format(<EOL>ast_name.asname if ast_name.asname is not None else ast_name.name,<EOL>called_func<EOL>)<EOL>s.add(call)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return s<EOL>
scan the abstract source tree looking for possible ways to call the called_module
and called_func

borrowed from pout

ast_tree -- _ast.* instance -- the internal ast object that is being checked, returned from compile()
    with ast.PyCF_ONLY_AST flag
called_module -- string -- we are checking the ast for imports of this module
called_func -- string -- we are checking the ast for aliases of this function
return -- set -- the list of possible calls the ast_tree could make to call the called_func