private void collectTimes(Tree tree,NodeRef node,Set<NodeRef> excludeNodesBelow,Intervals intervals){
  intervals.addCoalescentEvent(tree.getNodeHeight(node));
  for (int i=0; i < tree.getChildCount(node); i++) {
    NodeRef child=tree.getChild(node,i);
    boolean include=true;
    if (excludeNodesBelow != null && excludeNodesBelow.contains(child)) {
      include=false;
    }
    if (!include || tree.isExternal(child)) {
      intervals.addSampleEvent(tree.getNodeHeight(child));
    }
 else {
      collectTimes(tree,child,excludeNodesBelow,intervals);
    }
  }
}

private void collectTimes ( Tree tree , NodeRef node , Set < NodeRef > excludeNodesBelow , Intervals intervals ) { intervals . addCoalescentEvent ( tree . getNodeHeight ( node ) ) ; for ( int i = 0 ; i < tree . getChildCount ( node ) ; i ++ ) { NodeRef child = tree . getChild ( node , i ) ; boolean include = true ; if ( excludeNodesBelow != null && excludeNodesBelow . contains ( child ) ) { include = false ; } if ( ! include || tree . isExternal ( child ) ) { intervals . addSampleEvent ( tree . getNodeHeight ( child ) ) ; } else { collectTimes ( tree , child , excludeNodesBelow , intervals ) ; } } }
extract coalescent times and tip information into arraylist times from tree .
