Test if component exist

How can i test, if a component exist.
If the component exist, i want to remove it.

// New text field with caption "Name"
TextField name = new TextField("Name");
layout.addComponent(name);

Now i want to remove this component, but only if it exists because of NullPointer Exception.

Somethink like this:

if (name.exist())
layout.removeComponent(name);

isAttached() or getParent()==layout