ObjectId SaveTree (NGit.Tree tree, HashSet<NGit.Tree> modifiedTrees)
		{
			// Saves tree that have been modified (that is, which are in the provided list or
			// which have child trees that have been modified)
			
			bool childModified = false;
			foreach (var te in tree.Members ()) {
				NGit.Tree childTree = te as NGit.Tree;
				if (childTree != null) {
					ObjectId newId = SaveTree (childTree, modifiedTrees);
					if (newId != null) {
						childTree.SetId (newId);
						childModified = true;
					}
				}
			}
			if (childModified || modifiedTrees.Contains (tree)) {
				var writer = repo.ObjectDatabase.NewInserter ();
				try {
					return writer.Insert (Constants.OBJ_TREE, tree.Format ());
				} finally {
					writer.Release ();
				}
			} else
				return null;
		}