A New York mom is caught between a rock and an appellate court.

The upstate woman has been told she needs to ditch a driveway decoration painted with a Confederate flag or risk losing custody of her mixed-race child -- even though a Family Court judge didn’t consider it to be an issue when it was raised during trial.

"Given that the child is of mixed race, it would seem apparent that the presence of the flag is not in the child’s best interests, as the mother must encourage and teach the child to embrace her mixed race identity, rather than thrust her into a world that only makes sense through the tortured lens of cognitive dissonance," appeals judges wrote in a ruling released Thursday.

The "presence of the Confederate flag," when "viewed pragmatically," "is a symbol inflaming the already strained relationship between the parties," the judges found.

They ruled if the rock is not removed by June 1, "its continued presence shall constitute a change in circumstances," meaning the parents’ custody agreement could be revisited, and "Family Court shall factor this into any future best interests analysis."

IHOP RESPONDS TO ADAM SANDLER WITH ALL-YOU-CAN-DRINK-MILKSHAKES

The parents — identified only as Christie and Isaiah in the documents — have long had joint legal custody of the girl, born in 2014, but the mother wants the dad to only see his daughter every other weekend, and the father wants sole custody.

While he raised the issue of the rock previously during their custody trial, the father made a broader argument to the court that his home was more suitable for the girl.

The case made its way to the appellate court in Albany, which brought the rock to the forefront of the dispute.

"Although not addressed by Family Court or the attorney for the child, the mother’s testimony at the hearing, as well as an exhibit admitted into evidence, reveal that she has a small confederate flag painted on a rock near her driveway," the judges wrote in the ruling.

Jason Leifer, the lawyer representing the child, said it was like the appellate judges "pulled something out of a hat," because the rock was never the subject of the parents’ disagreements.

"Bringing politics into the family court is probably the worst possible thing you could do, and it seems like that’s what the appellate division has opened the door to," Leifer told The Post by phone.

"Hopefully it’ll be fixed by the Court of Appeals."

CUOMO COMMUNICATIONS DIRECTOR RESIGNS, JOINS OTHERS WHO HAVE JUMPED SHIP AMID SCANDALS

Amid a modern-day civil-rights movement after the police killing of George Floyd in Minneapolis, the use of the Confederate flag has come under intense scrutiny, with many opponents arguing it is a "symbol of racism and slavery" and "inappropriate for public display," according to Britannica. 

In December, Gov. Andrew Cuomo signed a law preventing the sale of Confederate flags and other "hate symbols" like it, such as the swastika, on state property. The law also severely limits the flag’s display unless deemed relevant to serving an educational or historical purpose.

Proponents of the flag argue it recalls "Southern heritage and wartime sacrifice," Britannica says.

Regardless of its symbolism, Michael Stutman, an attorney specializing in matrimonial law and the current chair of the New York City Bar Association’s Matrimonial Law Committee, told The Post he thinks the judges made "a very dangerous statement."

"I think that it is a rather astonishing extension of wokeness in now that the door seems to be opening that someone’s political viewpoint reflects on their fitness as a parent," Stutman said.

CLICK HERE TO GET THE FOX NEWS APP

"It is one of the clearest infringements on someone’s free speech by the state to have a court threaten to restrict a parents’ rights to their child based upon … the propriety of a person’s political beliefs.

"I don’t think that such a decision would ever stand constitutional challenge," he said.

"You could easily find a conservative court saying that a person who flies a rainbow pride flag on their front door is an unfit parent because that judge does not believe in sexual choices, say, that are beyond that of just males and females," the lawyer added. "I think it was a real error."

The child’s mother could not be reached, but an attorney for the father told The Post he and his client "certainly … felt that the issue was important and needed to be raised."

This story first appeared in the New York Post.