class TreeWalker {

  public static boolean isAncestor(@NotNull Container ancestor, @NotNull Component child) {
    if (child == ancestor) {
      return true;
    }
    else if (child.getParent() == null) {
      return false;
    }
    else {
      return isAncestor(ancestor, child.getParent());
    }
  }

  public  TreeWalker(@NotNull Component root);

}