How to compare XML from session data with current state?

We’re trying to compare the state information is the XML saved in session data with the current state of our plugin, for AAX’s Compare ability. I’m using this function to compare, but for some reason it doesn’t compare correctly. At first, it returns true (equal), but after changing one parameter and changing it back, it returns false.

			if (pParameterTreeXml->hasTagName(parameters.state.getType()))
			ValueTree givenState = ValueTree::fromXml(*pParameterTreeXml);
			return (givenState.isEquivalentTo(parameters.state))

Also, it might be nice for some parameters to have more specific control over the comparison (such as a "slacK’ for how close a parameter needs to be, or the ability to ignore some parameters).

What I’m wondering is how I can compare, with more control, my value tree state with the state returned from ValueTree::fromXml?