Find duplicates using AST