Let's simplify this a bit:

    if (seen[sha]) return null;