Key words: Tree like hierarchy

UML

Composite Pattern

Composite1

<ul>
  <li>One</li>
  <li>Two</li>
  <li>Three</li>
  <li>Fourth
    <ul>
      <li>Fourth1</li>
      <li>Fourth2</li>
    </ul>
  </ul>
</ul>

Composite2

Pseudo Code

interface TodoList {
  String getHtml();
}

class Todo extends TodoList {
  String text;
  
  public Todo(String text) {
    this.text = text;
  }

  public String getHtml() {
    return this.text;
  }
}

class Project extends TodoList {
  String title;
  List<TodoList> todos;

  public Project(String title, List<TodoList> todos) {
    this.title = title;
    this.todos = todos;
  }

  public String getHtml() {
    String html = "<h1>";
    html += this.title;
    html += "</h1><ul>";
    for(TodoList todo : todos) {
      html += "<li>";
      html += todo.getHtml();
      html += "</li>";
    }
    html += "</ul>";

    return html;
  }
}

Reference