code: private Box locateBox(Box root, int x, int y)
      {
          if (root.isVisible())
          {
              Box found = null;
              Rectangle bounds = root.getAbsoluteContentBounds().intersection(root.getClipBlock().getClippedContentBounds());
              if (bounds.contains(x, y))
                  found = root;
              
              //find if there is something smallest that fits among the child boxes
              if (root instanceof ElementBox)
              {
                  ElementBox eb = (ElementBox) root;
                  for (int i = eb.getStartChild(); i < eb.getEndChild(); i++)
                  {
                      Box inside = locateBox(((ElementBox) root).getSubBox(i), x, y);
                      if (inside != null)
                      {
                          if (found == null)
                              found = inside;
                          else
                          {
                              if (inside.getAbsoluteBounds().width * inside.getAbsoluteBounds().height < found.getAbsoluteBounds().width * found.getAbsoluteBounds().height)
                                  found = inside;
                          }
                      }
                  }
              }
              return found;
          }
          else
              return null;
      }
docs: Locates a box from its position