code: private void computeRootStatistics(Area root)
      {
          if (root.isBackgroundSeparated())
          {
              Color color = root.getBackgroundColor();
      
              if (color != null)
              {
                  int key = colorKey(color);
                  Integer val = colors.get(key);
                  if (val == null) val = 0;
                  val += root.getBounds().getArea();
                  colors.put(key, val);
              }
          }
          
          for (int i = 0; i < root.getChildCount(); i++)
              computeRootStatistics(root.getChildAt(i));
      }
      
      /**
       * Converts a color to a number, 4 bits per color channel so that similar colors have similar numbers.
       */
      private int colorKey(Color color)
      {
          return (color.getRed() / 16) * 256 + (color.getGreen() / 16) * 16 + (color.getBlue() / 16);
      }
  
      /**
       * Computes the effective (visible) background color of an area considering
       * transparency and parent areas.
       * @param area The area
       * @return the visible background color
       */
      public static Color getEffectiveBackgroundColor(Area area)
      {
          if (area.getBackgroundColor() != null)
              return area.getBackgroundColor();
          else
          {
              if (area.getParent() != null)
                  return getEffectiveBackgroundColor(area.getParent());
              else
                  return Color.WHITE; //use white as the default root color
          }
      }
      
  }
docs: Recursively computes the statistics of the individual colors in a subtree.
  @param root the root of the subtree