Okay.

You need an attorney in NH. While the divorce was out of MA, NH has been the child's habitual residence and would have (or would easily obtain) jurisdiction per UCCJEA .

I'm not entirely sure why you were told (or you implied?) that getting a DNA test would enable you to bring the child back to NH and start a custody battle. A positive DNA test would only give you standing to sue - it would not give you any rights to remove the child. The positive DNA test would be submitted to the court as part of the request to disestablish Legal Dad's paternity. If the court allows that, and allows you to establish paternity, THEN you could file for custody (or at the very least an enforceable visitation plan).

If the court denies your request - again, it's game over.

(And in NH, you wouldn't have standing to sue for third party visitation or de facto standing, I'm afraid)