There's an old project from Facebook that does something like this, called Pfff[0]
It provides a tool called sgrep (syntactical grep) that lets you do some cool tricks, for instance:
`sgrep "some_func(X,X)"` returns all calls to some_func with the same argument repeated.
`sgrep "some_func(X,Y,...)"` returns all calls to some_func with 3 or more arguments.
It's come in very handy for refactoring some troublesome codebases.