/**
   * Lay out the leftmost incomplete branch of this connection node.
   *
   * @param connectionNode
   */
  public boolean layoutBranch(
      VisualConnection connectionNode, BarState currentState, int totalWidth) {

    // If this node isn't laid out already, lay it out.
    if (!connectionNode.isLaidOut()) {

      connectionNode.layout(connectionNode.getParent().getWidth());
      connectionNode.setLaidOut(true);

      // If this is a leaf, this node is completed.
      if (connectionNode.getChildren().isEmpty()) {
        connectionNode.setComplete(true);
        return true;
      }
    }

    // If this is not a leaf, call layoutBranch on this node's
    // leftmost incomplete child.
    for (VisualConnection child : connectionNode.getChildren())
      if (!child.isComplete())
        if (layoutBranch(child, currentState, totalWidth) == false) return false;

    // If all of the children are complete, this node is
    // completed.
    connectionNode.setComplete(true);

    return true;
  }
  public void resetForBundling(VisualConnection connectionNode) {
    connectionNode.setComplete(false);
    connectionNode.setLaidOut(false);

    for (VisualConnection child : connectionNode.getChildren()) resetForBundling(child);
  }