def METHOD_NAME (videosink):
  pipe = videosink.get_parent()
  if pipe == None:
    return
  sink_pad = videosink.get_static_pad ("sink")
  peer = sink_pad.get_peer()
  if peer != None:
    peer_element = peer.get_parent_element()
    if peer_element != None:
      if peer_element.get_factory().get_name() != "agnosticbin":
        METHOD_NAME(peer_element)
      else:
        print ("releasing pad: " + str(peer))
        peer_element.release_request_pad (peer)
  pipe.remove(videosink)
  videosink.set_state(Gst.State.NULL)