tree structures are often used, when coding with various goals or values, to condense conceptual parts so as to make them reusable across different parts of data.
they describe data as a graph.
so, usually you need a tree structure in coding, when you have goals and values around making software. a tree structure can often help meet them.