Writing PTree objects data to MongDB.