class Rake::InvocationChain

def member?(invocation)

Is the invocation already in the chain?
def member?(invocation)
  head == invocation || tail.member?(invocation)
end