A summary of grandparent visitation laws by state can be found here. The general rule is that it is whatever is in the interest of the child, and a judge determines that. In New York you may petition for visitation rights if one or both of the parents are dead, or there are "special circumstances". In E.S. v P.D. it was held that state law "does not create an absolute or automatic right of visitation", but it does create a "procedural mechanism for grandparents to acquire standing to seek visitation with a minor grandchild" (usually, grandparents do not have standing). In the particular case the grandmother had automatic standing owing to the death of her daughter.