If you go back and examine the code that produced this Data param, you can probably apply these methods earlier in the process to keep the tree from getting wacky.
I wrote this simple tool to visually examine the geometry in data trees and use it all the time: