Just a guess, as I couldn’t find the particular forest multipolygon that’s causing you trouble and have only scanned your code, but: Are you handling non-closed ways correctly? Any outer or inner ring of a multipolygon may potentially consist of more than one way, like in this illustration: