code: private static void PTC1(Program program, TreeNode parent_node, double p, int allowableDepth, RandEngine randEngine)
     {
        int child_count = parent_node.arity();
  
        for (int i = 0; i != child_count; i++)
        {
           Primitive data;
           if (allowableDepth == 0)
           {
              data = program.anyTerminal(randEngine);
           }
           else if (randEngine.uniform() <= p)
           {
              data = program.anyOperator(randEngine);
           }
           else
           {
              data = program.anyTerminal(randEngine);
           }
  
           TreeNode child = new TreeNode(data);
           parent_node.getChildren().add(child);
  
           if(!data.isTerminal())
           {
              PTC1(program, child, p, allowableDepth - 1, randEngine);
           }
        }
     }
docs: / <param name="allowableDepth">The maximum tree depth</param>