If you must store the tree exactly as it is in memory, then try this:
give each element of your tree an extra value to store a record number. (a long should work)
starting at the leaf nodes, write that to your file and mark it's record number sequentially. You're recording them first because they don't point to any other nodes.
As you write nodes that point to other nodes, instead of storing the pointer, you'll store the record number of the node it points to.
As you read the file back in, you'll rebuild your tree from the bottom up with the root being the last node read in.
example: ('->' means 'points to')
\ / \
b d f
write your leafs and record ids:
write other nodes,record ids, and pointed to record ids:
When you read them back in, it may be easier to create an array of pointers, create each node, and assign the pointers to the element in the array.
read in leafs:
add a to array
(b,d,f,a->b) (b is element 1, so use that pointer)
add e to array
(b,d,f,a->b,e->d,f) (d,f are elements 2,3)
repeat until no more elements to read, last element read is your root.