The magic money tree problem I thought of this problem in the shower, it was inspired by investment strategies. 
Let's say there was a magic money tree. Every day, you can offer an amount of money to the money tree and it will either triple it, or destroy it with 50/50 probability. You immediately notice that on average you will gain money by doing this and are eager to take advantage of the money tree. However, if you offered all your money at once, you would have a 50% of losing all your money. Unacceptable! You are a pretty risk-averse person, so you decide to come up with a strategy. You want to minimize the odds of losing everything, but you also want to make as much money as you can! You come up with the following: every day, you offer 20% of your current capital to the money tree. Assuming the lowest you can offer is 1 cent, it would take a 31 loss streak to lose all your money if you started with 10 dollars. What's more, the more cash you earn, the longer the losing streak needs to be for you to lose everything, amazing! You quickly start earning loads of cash. But then an idea pops into your head: you can just offer 30% each day and make way more money! But wait, why not offer 35%? 50%? One day, with big dollar signs in your eyes you run up to the money tree with all your millions and offer up 100% of your cash, which the money tree promptly burns. The next day you get a job at McDonalds. 
Is there an optimal percentage of your cash you can offer without losing it all? 
(sub) questions: 
If there is an optimal percentage you should offer, is this static (i.e. 20% every day) or should the percentage grow as your capital increases? 
By offering 20% every day, do the odds of losing all your money decrease or increase over time? Is there a percentage of money from where the odds of losing all your money increase over time?
 A: I don't think this is much different from the Martingale. In your case, there are no doubling bets, but the winning payout is 3x.
I coded a "living replica" of your tree. I run 10 simulations. In each simulation (trace), you start with 200 coins and try with the tree, 1 coin each time for 20,000 times.
The only conditions that stop the simulation are bankruptcy or having "survived" 20k attempts

I think that whatever the odds, sooner or later bankruptcy awaits you.

The code is improvised javascript but dependency-free: https://repl.it/@cilofrapez/MagicTree-Roulette
It shows you the results straight away. The code is simple to tweak: to run however many simulations, bet amount, however many attempts... Feel free to play!
At the bottom of the code, each simulation's (by default 10) results are saved into a CSV file with two columns: spin number and money. I made that so it could be fed it to an online plotter for the graphs.
It'd be effortless to have it all automated locally using the Google Charts library for example. If you only want to see the results on the screen, you can comment that last part out as I mentioned in the file.
EDIT
Source code:
/**
 * License: MIT
 * Author: Carles Alcolea, 2019
 * Usage: I recommend using an online solution like repl.it to run this code.
 * Nonetheless, having node installed, it's as easy as running `node magicTree.js`.
 *
 * The code will run `simulations` number of scenarios, each scenario is equal in settings
 * which are self-descriptive: `betAmount`,`timesWinPayout`, `spinsPerSimulation`, `startingBankRoll`
 * and `winningOdds`.
 *
 * At the end of the code there's a part that will generate a *.csv file for each simulation run.
 * This is useful for ploting the resulting data using any such service or graphing library. If you
 * wish the code to generate the files for you, just set `saveResultsCSV` to true. All files will
 * have two columns: number of spin and current bankroll.
 */

const fs = require('fs'); // Only necessary if `saveResultsCSV` is true

/**
 * ==================================
 * You can play with the numbers of the following variables all you want:
 */
const betAmount          = 0.4,   // Percentage of bankroll that is offered to the tree
      winningOdds        = 0.5,
      startingBankRoll   = 200,
      timesWinPayout     = 2,
      simulations        = 5,
      spinsPerSimulation = 20000,
      saveResultsCSV     = false;
/**
 * ==================================
 */

const simWins = [];
let currentSim = 1;

//* Each simulation:
while (currentSim <= simulations) {
  let currentBankRoll = startingBankRoll,
      spin            = 0;
  const resultsArr  = [],
        progressArr = [];

  //* Each spin/bet:
  while (currentBankRoll > 0 && spin < spinsPerSimulation) {
    if (currentBankRoll === Infinity) break; // Can't hold more cash!
    let currentBet = Math.ceil(betAmount * currentBankRoll);
    if (currentBet > currentBankRoll) break;  // Can't afford more bets... bankrupt!

    const treeDecision = Math.random() < winningOdds;
    resultsArr.push(treeDecision);
    if (treeDecision) currentBankRoll += currentBet * timesWinPayout; else currentBankRoll -= currentBet;
    progressArr.push(currentBankRoll);
    spin++;
  }

  const wins = resultsArr.filter(el => el === true).length;
  const losses = resultsArr.filter(el => el === false).length;
  const didTheBankRollHold = (resultsArr.length === spinsPerSimulation) || currentBankRoll === Infinity;

  const progressPercent = didTheBankRollHold ? `(100%)` : `(Bankrupt at aprox ${((resultsArr.length / parseFloat(spinsPerSimulation)) * 100).toPrecision(4)}% progress)`;

  // Current simulation summary
  console.log(`
  - Simulation ${currentSim}: ${progressPercent === '(100%)' ? '✔' : '✘︎'}
    Total:      ${spin} spins out of ${spinsPerSimulation} ${progressPercent}
    Wins:       ${wins} (aprox ${((wins / parseFloat(resultsArr.length)) * 100).toPrecision(4)}%)
    Losses:     ${losses} (aprox ${((losses / parseFloat(resultsArr.length)) * 100).toPrecision(4)}%)
    Bankroll:   ${currentBankRoll}
  `);

  if (didTheBankRollHold) simWins.push(1);

  /**
   * ==================================
   * Saving data?
   */
  if (saveResultsCSV) {
    let data = `spinNumber, bankRoll`;
    if (!fs.existsSync('CSVresults')) fs.mkdirSync('CSVresults');
    progressArr.forEach((el, i) => {
      data += `\n${i + 1}, ${el}`;
    });
    fs.writeFileSync(`./CSVresults/results${currentSim}.csv`, data);
  }
  /**
   * ==================================
   */

  currentSim++;
}

// Total summary
console.log(`We ran ${simulations} simulations, with the goal of ${spinsPerSimulation} spins in each one.
Our bankroll (${startingBankRoll}) has survived ${simWins.length} out of ${simulations} simulations, with ${(1 - winningOdds) * 100}% chance of winning.`);
```

A: I liked the answer given by Dave harris. just though I would come at the problem from a "low risk" perspective, rather than profit maximising
The random walk you are doing, assuming your fraction bet is $q$ and probability of winning $p=0.5$ has is given as
$$Y_t|Y_{t-1}=(1-q+3qX_t)Y_{t-1}$$
where $X_t\sim Bernoulli(p)$. on average you have
$$E(Y_t|Y_{t-1}) = (1-q+3pq)Y_{t-1}$$
You can iteratively apply this to get
$$Y_t|Y_0=Y_0\prod_{j=1}^t (1-q+3qX_t)$$
with expected value
$$E(Y_t|Y_{0}) = (1-q+3pq)^t Y_{0}$$
you can also express the amount at time $t$ as a function of a single random variable $Z_t=\sum_{j=1}^t X_t\sim Binomial(t,p)$, but noting that $Z_t$ is not independent from $Z_{t-1}$
$$Y_t|Y_0=Y_0 (1+2q)^{Z_t}(1-q)^{t-Z_t}$$
possible strategy
you could use this formula to determine a "low risk" value for $q$. Say assuming you wanted to ensure that after $k$ consecutive losses you still had half your original wealth. Then you set $q=1-2^{-k^{-1}}$
Taking the example $k=5$ means we set $q=0.129$, or with $k=15$ we set $q=0.045$.
Also, due to the recursive nature of the strategy, this risk is what you are taking every at every single bet. That is, at time $s$, by continuing to play you are ensuring that at time $k+s$ your wealth will be at least $0.5Y_{s}$
discussion
the above strategy does not depend on the pay off from winning, but rather about setting a boundary on losing. We can get the expected winnings by substituting in the value for $q$ we calculated, and at the time $k$ that was used with the risk in mind.
however, it is interesting to look at the median rather than expected pay off at time $t$, which can be found by assuming $median(Z_t)\approx tp$. 
$$Y_k|Y_0=Y_0 (1+2q)^{tp}(1-q)^{t(1-p)}$$
when $p=0.5$ the we have the ratio equal to $(1+q-2q^2)^{0.5t}$. This is maximised when $q=0.25$ and greater than $1$ when $q<0.5$
it is also interesting to calculate the chance you will be ahead at time $t$. to do this we need to determine the value $z$ such that
$$(1+2q)^{z}(1-q)^{t-z}>1$$
doing some rearranging we find that the proportion of wins should satisfy
$$\frac{z}{t}>\frac{\log(1-q)}{\log(1-q)-\log(1+2q)}$$
This can be plugged into a normal approximation (note: mean of $0.5$ and standard error of $\frac{0.5}{\sqrt{t}}$) as
$$Pr(\text{ahead at time t})\approx\Phi\left(\sqrt{t}\frac{\log(1+2q)+\log(1-q)}{\left[\log(1+2q)-\log(1-q)\right]}\right)$$
which clearly shows the game has very good odds. the factor multiplying $\sqrt{t}$ is minimised when $q=0$ (maximised value of $\frac{1}{3}$) and is monotonically decreasing as a function of $q$. so the "low risk" strategy is to bet a very small fraction of your wealth, and play a large number of times.
suppose we compare this with $q=\frac{1}{3}$ and $q=\frac{1}{100}$. the factor for each case is $0.11$ and $0.32$. This means after $38$ games you would have around a 95% chance to be ahead with the small bet, compared to a 75% chance with the larger bet. Additionally, you also have a chance of going broke with the larger bet, assuming you had to round your stake to the nearest 5 cents or dollar. Starting with $20$ this could go $13.35, 8.90,5.95,3.95,2.65,1.75,1.15,0.75,0.50,0.35,0.25,0.15,0.1,0.05,0$.
This is a sequence of $14$ losses out of $38$, and given the game would expect $19$ losses, if you get unlucky with the first few bets, then even winning may not make up for a bad streak (e.g., if most of your wins occur once most of the wealth is gone). going broke with the smaller 1% stake is not possible in $38$ games.
The flip side is that the smaller stake will result in a much smaller profit on average, something like a $350$ fold increase with the large bet compared to $1.2$ increase with the small bet (i.e. you expect to have 24 dollars after 38 rounds with the small bet and 7000 dollars with the large bet).
A: This is a well-known problem.  It is called a Kelly bet.  The answer, by the way, is 1/3rd.  It is equivalent to maximizing the log utility of wealth.
Kelly began with taking time to infinity and then solving backward.  Since you can always express returns in terms of continuous compounding, then you can also reverse the process and express it in logs.  I am going to use the log utility explanation, but the log utility is a convenience.  If you are maximizing wealth as $n\to\infty$ then you will end up with a function that works out to be the same as log utility.  If $b$ is the payout odds, and $p$ is the probability of winning, and $X$ is the percentage of wealth invested, then the following derivation will work.
For a binary bet, $E(\log(X))=p\log(1+bX)+(1-p)\log(1-X)$, for a single period and unit wealth.
$$\frac{d}{dX}{E[\log(x)]}=\frac{d}{dX}[p\log(1+bX)+(1-p)\log(1-X)]$$
$$=\frac{pb}{1+bX}-\frac{1-p}{1-X}$$
Setting the derivative to zero to find the extrema,
$$\frac{pb}{1+bX}-\frac{1-p}{1-X}=0$$
Cross multiplying, you end up with $$pb(1-X)-(1-p)(1+bX)=0$$
$$pb-pbX-1-bX+p+pbX=0$$
$$bX=pb-1+p$$
$$X=\frac{bp-(1-p)}{b}$$
In your case, $$X=\frac{3\times\frac{1}{2}-(1-\frac{1}{2})}{3}=\frac{1}{3}.$$
You can readily expand this to multiple or continuous outcomes by solving the expected utility of wealth over a joint probability distribution, choosing the allocations and subject to any constraints.  Interestingly, if you perform it in this manner, by including constraints, such as the ability to meet mortgage payments and so forth, then you have accounted for your total set of risks and so you have a risk-adjusted or at least risk-controlled solution.
Desiderata  The actual purpose of the original research had to do with how much to gamble based on a noisy signal.  In the specific case, how much to gamble on a noisy electronic signal where it indicated the launch of nuclear weapons by the Soviet Union.  There have been several near launches by both the United States and Russia, obviously in error.  How much do you gamble on a signal?
