How can I query the panels in the Tool Shelf from a script?
If you wanna check the appended (or prepended) draw functions of another addons, added to built-in panels, you can do for example:

draw_method = bpy.types.OBJECT_OT_relations.draw
if hasattr(draw_method, "_draw_funcs"):
    print(draw_method._draw_funcs)


As soon as a custom draw function is added, _draw_funcs will be defined and contain a list of draw functions. They are stored in a list, which means you can pop/remove/insert/append/prepend or shuffle the entries.

A really advanced possibility is to intercept all draw calls, but beware! Only a single addon may do this at a time, or you'll run into errors.

http://wiki.blender.org/index.php/User:Ideasman42/Blender_UI_Shenanigans