Created functions to serialize tree traversal nodes during testing (for each data point)