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");

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

Somethink like this:

if (name.exist())

isAttached() or getParent()==layout