The object that is compared to `result` is exactly the same as the object given to `autoMergeDocument`. I think you should use a variable instead to remove duplication.