title: Refactor recursive modifications of tree
body: <p>How can I refactor the following code:</p>
  
  <pre><code>class ModifyTree{
      public void doActionsOnTree(Tree tree) {
          rAction1(tree.getRoot());
          rAction2(tree.getRoot());
      }
  
      private void action1(Node node) {
          // do something with node;
      }
  
      private void action2 (Node node) {
          // do something with node
      }
  
      private void rAction1(Node node) {
          action1(node);
          for(Node nodeIterator : node.getChildren())
              rAction1(nodeIterator);
      }
  
      private void rAction2(Node node) {
          action2(node);
          for(Node nodeIterator : node.getChildren())
              rAction2(nodeIterator);
      }
  }
  </code></pre>
  
  <p>Methods <code>rAction1()</code> and <code>rAction2()</code> looks very similarly. Is there a way to don't repeat the code in this case?</p>