Fix determining reference paths for formatting data with circular references