code: public static int graphDepth (Layer layer) {
      int depth = -1;
      while (layer != null) {
        layer = layer.parent();
        depth++;
      }
      return depth;
    }
docs: Returns the depth of the given layer in its local scene graph. A root layer (one with null
  parent) will always return 0.