if (ancestor != root)
if (ancestor == null) ancestor = root; else if (ancestor != root)
  public Component getComponentBefore (Container root, Component current)  {    if (root == null)      throw new IllegalArgumentException ("focus cycle root is null");    if (current == null)      throw new IllegalArgumentException ("current component is null");    if (!root.isFocusCycleRoot ())      throw new IllegalArgumentException ("root is not a focus cycle root");    Container ancestor = current.getFocusCycleRootAncestor ();    Container prevAncestor = ancestor;    while (ancestor != root)      {	ancestor = current.getFocusCycleRootAncestor ();	if (ancestor == prevAncestor)	  {	    // We've reached the top focus cycle root ancestor.  Check	    // if it is root.	    if (ancestor != root)	      throw new IllegalArgumentException ("the given container is not"						  + " a focus cycle root of the"						  + " current component");	    else	      break;	  }	prevAncestor = ancestor;      }    // FIXME: is this the right thing to do here? It moves the context    // for traversal up one focus traversal cycle.  We'll need a test    // for this.    if ((Component) root == current)      root = current.getFocusCycleRootAncestor ();    // Check if we've reached the top of the component hierarchy.  If    // so then we want to loop around to the last component in the    // focus traversal cycle.    if (current instanceof Window)      return getLastComponent ((Container) current);    Container parent = current.getParent ();    synchronized (parent.getTreeLock ())      {        Component[] components = parent.getComponents ();        int componentIndex = 0;        int numComponents = parent.getComponentCount ();        // Find component's index.        for (int i = 0; i < numComponents; i++)          {            if (components[i] == current)              componentIndex = i;          }        // Search backward for the next acceptable component.        for (int i = componentIndex - 1; i >= 0; i--)          {            if (accept (components[i]))              return components[i];            if (components[i] instanceof Container)              {                Component result = getLastComponent ((Container) components[i]);                if (result != null)                  return result;  }          }        // No focusable components before current in its Container.  So go        // to the previous Component before current's Container (parent).        Component result = getComponentBefore (root, parent);        return result;      }  }