code: public static Node getEnclosingType(Node n, final Token type) {
      return getEnclosingNode(
          n,
          new Predicate<Node>() {
            @Override
            public boolean apply(Node n) {
              return n.getToken() == type;
            }
          });
    }
docs: Gets the closest ancestor to the given node of the provided type.