public void addChild(Component component) {
    if (component.parent != null) {
      component.parent.directChildren.remove(component);
      removeIndexComponent(component.parent, component);
    }

    component.parent = this;
    this.directChildren.add(component);
    indexComponent(this, component);
  }
  public Component(String id, ComponentType type, Component parent) {
    this.id = id;
    this.type = type;
    this.parent = null;
    directChildren = new ArrayList<>();
    attributes = new Attributes(this.id);
    allChildren = new HashMap<>();
    attributeId = new HashMap<>();

    initAttributesId();
    parent.addChild(this);
  }
  public Component(Component parent) {
    this.id = generateCustomId();
    this.type = ComponentType.PANEL;
    this.parent = parent;
    directChildren = new ArrayList<>();
    attributes = new Attributes(this.id);
    allChildren = new HashMap<>();
    attributeId = new HashMap<>();

    initAttributesId();
    parent.addChild(this);
  }
  private void clone(Component original, Component parent, String suffix) {
    Component clone = new Component(original.id + suffix, original.type, parent);

    clone.attributes = original.attributes.clone(clone.getId());
    clone.setAttributeId(ComponentState.NORMAL, clone.getId() + "NORMAL");
    clone.setAttributeId(ComponentState.HOVER, clone.getId() + "HOVER");
    clone.setAttributeId(ComponentState.CLICK, clone.getId() + "CLICK");

    for (Component copy : original.directChildren) clone(copy, clone, suffix);
  }
  public Component clone(String suffix, boolean fakeParent) {
    Component clone;

    if (fakeParent && this.parent != null)
      clone =
          new Component(
              this.id + suffix, this.type, new Component(this.parent.getId(), ComponentType.PANEL));
    else if (this.parent != null) clone = new Component(this.id + suffix, this.type, this.parent);
    else clone = new Component(this.id + suffix, this.type);

    clone.attributes = attributes.clone(clone.getId());
    clone.setAttributeId(ComponentState.NORMAL, clone.getId() + "NORMAL");
    clone.setAttributeId(ComponentState.HOVER, clone.getId() + "HOVER");
    clone.setAttributeId(ComponentState.CLICK, clone.getId() + "CLICK");

    for (Component copy : directChildren) clone(copy, clone, suffix);

    return clone;
  }