It might have had good moments but no judge is going to make such a ruling. They would order a paternity test to determine who gets custody of the child it there are no stipulations in a will by the deceased. I know sometimes for sitcoms you have to suspend disbelief but not this much. Plenty of sitcoms were successful without such a far fetched premise.